Class: InstanceKey
- Inherits:
-
Struct
- Object
- Struct
- InstanceKey
- Defined in:
- backend/app/lib/user_defined_field_migrator.rb
Instance Attribute Summary collapse
-
#barcode ⇒ Object
Returns the value of attribute barcode.
-
#indicator ⇒ Object
Returns the value of attribute indicator.
-
#resource_component_id ⇒ Object
Returns the value of attribute resource_component_id.
-
#resource_id ⇒ Object
Returns the value of attribute resource_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(resource_id, resource_component_id, barcode, indicator) ⇒ InstanceKey
constructor
A new instance of InstanceKey.
-
#to_bytes ⇒ Object
-
#valid? ⇒ Boolean
Constructor Details
#initialize(resource_id, resource_component_id, barcode, indicator) ⇒ InstanceKey
Returns a new instance of InstanceKey.
305 306 307 308 309 310 |
# File 'backend/app/lib/user_defined_field_migrator.rb', line 305 def initialize(resource_id, resource_component_id, , indicator) super(self.class.stringify(resource_id), self.class.stringify(resource_component_id), self.class.stringify(), self.class.stringify(indicator)) end |
Instance Attribute Details
#barcode ⇒ Object
Returns the value of attribute barcode
284 285 286 |
# File 'backend/app/lib/user_defined_field_migrator.rb', line 284 def end |
#indicator ⇒ Object
Returns the value of attribute indicator
284 285 286 |
# File 'backend/app/lib/user_defined_field_migrator.rb', line 284 def indicator @indicator end |
#resource_component_id ⇒ Object
Returns the value of attribute resource_component_id
284 285 286 |
# File 'backend/app/lib/user_defined_field_migrator.rb', line 284 def resource_component_id @resource_component_id end |
#resource_id ⇒ Object
Returns the value of attribute resource_id
284 285 286 |
# File 'backend/app/lib/user_defined_field_migrator.rb', line 284 def resource_id @resource_id end |
Class Method Details
.from_row(row) ⇒ Object
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'backend/app/lib/user_defined_field_migrator.rb', line 286 def self.from_row(row) if row[:barcode].nil? && row[:container1AlphaNumIndicator].nil? && row[:container1NumericIndicator].nil? # This cannot be matched to a TopContainer return nil end = stringify(row[:barcode]) if indicator = nil elsif (indicator = stringify(row[:container1AlphaNumIndicator])) else indicator = sprintf("%g", row[:container1NumericIndicator]) end new(row[:resourceId], row[:resourceComponentId], , indicator) end |
.stringify(value) ⇒ Object
313 314 315 316 317 318 319 |
# File 'backend/app/lib/user_defined_field_migrator.rb', line 313 def self.stringify(value) if value == "" || value.nil? nil else value.to_s end end |
Instance Method Details
#to_bytes ⇒ Object
321 322 323 |
# File 'backend/app/lib/user_defined_field_migrator.rb', line 321 def to_bytes Digest::SHA1.digest(self.to_json) end |
#valid? ⇒ Boolean
326 327 328 |
# File 'backend/app/lib/user_defined_field_migrator.rb', line 326 def valid? || indicator end |