Class: INatGet::Data::Parser::Part::Children Private
- Inherits:
-
Assoc
- Object
- INatGet::Data::Parser::Part
- Assoc
- INatGet::Data::Parser::Part::Children
- Defined in:
- lib/inat-get/data/parsers/defs/children.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
- #parse(target, source) ⇒ nil private
Methods inherited from Assoc
Methods inherited from INatGet::Data::Parser::Part
Constructor Details
This class inherits a constructor from INatGet::Data::Parser::Part::Assoc
Instance Method Details
#parse(target, source) ⇒ nil
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.
6 7 8 9 10 11 12 13 |
# File 'lib/inat-get/data/parsers/defs/children.rb', line 6 def parse target, source data = source[@source] || [] values = @model.parser.parse!(data.map { |r| r.is_a?(Hash) ? r.merge(owner_id: target.id) : { owner_id: target.id, value: r } }) pks = values.map { |v| v.primary_key } existing = target.send(@name) existing.reject { |r| pks.include?(r.primary_key) }.each(&:delete) if existing nil end |