Class: INatGet::Data::Parser::Part::AssModel Private
- Inherits:
-
Assoc
- Object
- INatGet::Data::Parser::Part
- Assoc
- INatGet::Data::Parser::Part::AssModel
- Defined in:
- lib/inat-get/data/parsers/defs/assmodel.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary
Attributes inherited from INatGet::Data::Parser::Part
Instance Method Summary collapse
-
#initialize(parser, name, model:, source: nil, source_id: nil) ⇒ AssModel
constructor
private
A new instance of AssModel.
- #parse(target, source) ⇒ Object private
Constructor Details
#initialize(parser, name, model:, source: nil, source_id: nil) ⇒ AssModel
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of AssModel.
7 8 9 10 11 12 13 |
# File 'lib/inat-get/data/parsers/defs/assmodel.rb', line 7 def initialize parser, name, model:, source: nil, source_id: nil super parser, name, model: model @name = name @model = model @source = source || @name @source_id = source_id || "#{@source}_id".to_sym end |
Instance Method Details
#parse(target, source) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/inat-get/data/parsers/defs/assmodel.rb', line 15 def parse target, source data = source[@source] if data { @name => @model.parser.entry!(data) } else id = source[@source_id] if id { @name => Array(@model.manager.get(id)).first } else { @name => nil } end end end |