Class: INatGet::Data::Parser::Part::PrjSearch Private
- Inherits:
-
Assoc
- Object
- INatGet::Data::Parser::Part
- Assoc
- INatGet::Data::Parser::Part::PrjSearch
- Defined in:
- lib/inat-get/data/parsers/defs/prjsearch.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) ⇒ PrjSearch
constructor
private
A new instance of PrjSearch.
- #make_quality_grades(p_id, quality_grades) ⇒ Object private private
- #make_terms(p_id, term_id, term_value_id) ⇒ Object private private
- #parse(target, source) ⇒ Object private
Constructor Details
#initialize(parser) ⇒ PrjSearch
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 PrjSearch.
5 6 7 |
# File 'lib/inat-get/data/parsers/defs/prjsearch.rb', line 5 def initialize parser super parser, nil, model: nil end |
Instance Method Details
#make_quality_grades(p_id, quality_grades) ⇒ Object (private)
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.
35 36 37 38 39 40 41 42 43 |
# File 'lib/inat-get/data/parsers/defs/prjsearch.rb', line 35 def make_quality_grades p_id, quality_grades qg_mod = INatGet::Data::Model::ProjectQualityGrade condition = Sequel.&({ project_id: p_id }, Sequel.~({ quality_grade: quality_grades })) qg_mod.where(condition).delete quality_grades -= qg_mod.where(project_id: p_id).select_map(:quality_grade) quality_grades.each do |qg| qg_mod.create project_id: p_id, quality_grade: qg end end |
#make_terms(p_id, term_id, term_value_id) ⇒ Object (private)
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.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/inat-get/data/parsers/defs/prjsearch.rb', line 45 def make_terms p_id, term_id, term_value_id pt_mod = INatGet::Data::Model::ProjectTerm condition = { project_id: p_id } if term_id && term_value_id record = pt_mod.with_pk p_id if record record.update term_id: term_id, term_value_id: term_value_id else pt_mod.create project_id: p_id, term_id: term_id, term_value_id: term_value_id end else pt_mod.where(condition).delete end end |
#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 23 24 25 26 27 28 29 30 31 |
# File 'lib/inat-get/data/parsers/defs/prjsearch.rb', line 9 def parse target, source return nil unless target.is_collection params = source[:search_parameters] quality_grades = [] term_id = nil term_value_id = nil members_only = false params.each do |para| case para[:field] when 'quality_grade' quality_grades = para[:value] when 'members_only' members_only = para[:value] when 'term_id' term_id = para[:value] when 'term_value_id' term_value_id = para[:value] end end make_quality_grades target.id, quality_grades make_terms target.id, term_id, term_value_id { members_only: members_only } end |