Class: INatGet::Data::Parser::Part::Subprojects Private
- Inherits:
-
Links
- Object
- INatGet::Data::Parser::Part
- Assoc
- Links
- INatGet::Data::Parser::Part::Subprojects
- Defined in:
- lib/inat-get/data/parsers/defs/subprojects.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) ⇒ Subprojects
constructor
private
A new instance of Subprojects.
- #parse(target, source) ⇒ Object private
Constructor Details
#initialize(parser) ⇒ Subprojects
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 Subprojects.
5 6 7 |
# File 'lib/inat-get/data/parsers/defs/subprojects.rb', line 5 def initialize parser super parser, :subprojects, model: INatGet::Data::Model::Project 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.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/inat-get/data/parsers/defs/subprojects.rb', line 9 def parse target, source return nil unless target.is_umbrella subprojects = [] params = source[:search_parameters] || [] params.each do |para| if para[:field] == 'project_id' subprojects += para[:value] end end manager = INatGet::Data::Manager::Projects::instance subprojects = manager.get(*subprojects).compact.map(&:id) field = @parser.model.association_reflection(@name)[:pks_setter_method].to_s.chomp("=").gsub('_setter', '').to_sym { field => subprojects } end |