Class: LabwareMetadata
- Inherits:
-
Object
- Object
- LabwareMetadata
- Defined in:
- app/models/labware_metadata.rb
Overview
rubocop:todo Style/Documentation
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#barcode ⇒ Object
Returns the value of attribute barcode.
-
#labware ⇒ Object
Returns the value of attribute labware.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ LabwareMetadata
constructor
A new instance of LabwareMetadata.
- #metadata ⇒ Object
-
#update!(metadata) ⇒ Object
rubocop:todo Metrics/AbcSize.
Constructor Details
#initialize(params = {}) ⇒ LabwareMetadata
Returns a new instance of LabwareMetadata.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/models/labware_metadata.rb', line 6 def initialize(params = {}) @api = params.fetch(:api, nil) @user = params.fetch(:user, nil) @barcode = params.fetch(:barcode, nil) if .present? @labware = find_labware(, api) else @labware = params.fetch(:labware, nil) raise ArgumentError, 'Parameters labware or barcode missing' if labware.nil? end raise ArgumentError, 'Parameter api missing' if api.nil? end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
4 5 6 |
# File 'app/models/labware_metadata.rb', line 4 def api @api end |
#barcode ⇒ Object
Returns the value of attribute barcode.
4 5 6 |
# File 'app/models/labware_metadata.rb', line 4 def @barcode end |
#labware ⇒ Object
Returns the value of attribute labware.
4 5 6 |
# File 'app/models/labware_metadata.rb', line 4 def labware @labware end |
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'app/models/labware_metadata.rb', line 4 def user @user end |
Instance Method Details
#metadata ⇒ Object
28 29 30 31 32 |
# File 'app/models/labware_metadata.rb', line 28 def @labware.. rescue URI::InvalidURIError nil end |
#update!(metadata) ⇒ Object
rubocop:todo Metrics/AbcSize
19 20 21 22 23 24 25 26 |
# File 'app/models/labware_metadata.rb', line 19 def update!() # rubocop:todo Metrics/AbcSize if labware..uuid.present? = labware...symbolize_keys labware..update!(metadata: .merge(.symbolize_keys)) else api..create!(user: user, asset: labware.uuid, metadata: .symbolize_keys) end end |