Class: INatGet::Data::Parser::Part::PK Private
- Inherits:
-
INatGet::Data::Parser::Part
- Object
- INatGet::Data::Parser::Part
- INatGet::Data::Parser::Part::PK
- Defined in:
- lib/inat-get/data/parsers/defs/pk.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, **aliases) ⇒ PK
constructor
private
A new instance of PK.
- #parse(source) ⇒ Object private
Constructor Details
#initialize(parser, **aliases) ⇒ PK
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 PK.
9 10 11 12 13 |
# File 'lib/inat-get/data/parsers/defs/pk.rb', line 9 def initialize parser, **aliases super parser @aliases = aliases @registered = Set::new end |
Instance Method Details
#parse(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 28 |
# File 'lib/inat-get/data/parsers/defs/pk.rb', line 15 def parse source @pk_cols ||= Array(parser.model.primary_key) result = {} @pk_cols.each do |col| src_col = @aliases[col] || col result[col] = source[src_col] end key = result.values_at(*@pk_cols) if @registered.include?(key) result[:_registered] = key end @registered << key result end |