Class: INatGet::Data::Parser::Part::Links Private

Inherits:
Assoc show all
Defined in:
lib/inat-get/data/parsers/defs/links.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.

Direct Known Subclasses

Ancestry, PrjMembers, Subprojects

Instance Attribute Summary

Attributes inherited from INatGet::Data::Parser::Part

#parser

Instance Method Summary collapse

Methods inherited from Assoc

#initialize

Methods inherited from INatGet::Data::Parser::Part

#initialize

Constructor Details

This class inherits a constructor from INatGet::Data::Parser::Part::Assoc

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.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/inat-get/data/parsers/defs/links.rb', line 5

def parse target, source
  data = source[@source]
  values = if data
    @model.parser.parse! data
  else
    ids = source[@source_ids] || []
    @model.manager.get(*ids)
  end
  ids = Array(values).map(&:id)
  field = @parser.model.association_reflection(@name)[:pks_setter_method].to_s.chomp('=').gsub('_setter', '').to_sym
  { field => ids }
end