Class: LedgerSync::Util::ResourceConverter::AttributeSet
- Inherits:
-
Object
- Object
- LedgerSync::Util::ResourceConverter::AttributeSet
- Includes:
- Mixins::DelegateIterableMethodsMixin
- Defined in:
- lib/ledger_sync/util/resource_converter/attribute_set.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#resource_converter_class ⇒ Object
readonly
Returns the value of attribute resource_converter_class.
Instance Method Summary collapse
- #add(attribute) ⇒ Object
- #hash_attribute?(key) ⇒ Boolean
-
#initialize(args = {}) ⇒ AttributeSet
constructor
A new instance of AttributeSet.
Methods included from Mixins::DelegateIterableMethodsMixin
Constructor Details
#initialize(args = {}) ⇒ AttributeSet
Returns a new instance of AttributeSet.
16 17 18 19 20 |
# File 'lib/ledger_sync/util/resource_converter/attribute_set.rb', line 16 def initialize(args = {}) @attributes = [] @attribute_keys = {} @resource_converter_class = args.fetch(:resource_converter_class) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
11 12 13 |
# File 'lib/ledger_sync/util/resource_converter/attribute_set.rb', line 11 def attributes @attributes end |
#resource_converter_class ⇒ Object (readonly)
Returns the value of attribute resource_converter_class.
11 12 13 |
# File 'lib/ledger_sync/util/resource_converter/attribute_set.rb', line 11 def resource_converter_class @resource_converter_class end |
Instance Method Details
#add(attribute) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ledger_sync/util/resource_converter/attribute_set.rb', line 22 def add(attribute) unless attribute.destination_attribute.nil? if @attribute_keys.key?(attribute.destination_attribute.to_s) raise "destination_attribute already defined for #{resource_converter_class.name}: "\ "#{attribute.destination_attribute}" end @attribute_keys[attribute.destination_attribute] = attribute end attributes << attribute attribute end |
#hash_attribute?(key) ⇒ Boolean
37 38 39 |
# File 'lib/ledger_sync/util/resource_converter/attribute_set.rb', line 37 def hash_attribute?(key) hash_attribute_keyed_hash.include?(key.to_s) end |