Sha256: 57a2cfc8799c9fd8dd166012d2ff919bd743ad66cfba15edca6e32f973117b26

Contents?: true

Size: 1.15 KB

Versions: 19

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require_relative '../mixins/delegate_iterable_methods_mixin'

module LedgerSync
  module Util
    class ResourceConverter
      class AttributeSet
        include Mixins::DelegateIterableMethodsMixin

        attr_reader :attributes,
                    :resource_converter_class

        delegate_array_methods_to :attributes

        def initialize(args = {})
          @attributes               = []
          @attribute_keys           = {}
          @resource_converter_class = args.fetch(:resource_converter_class)
        end

        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

        def hash_attribute?(key)
          hash_attribute_keyed_hash.include?(key.to_s)
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ledger_sync-2.6.0 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-2.5.0 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-2.4.4 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-2.3.1 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-2.2.3 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-2.2.1 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-2.2.0 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-2.0.2 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-2.0.1 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-2.0.0 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-2.0.0.pre.1 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-1.8.1 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-1.8.0 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-1.7.0 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-1.6.0 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-1.5.2 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-1.5.1 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-1.5.0 lib/ledger_sync/util/resource_converter/attribute_set.rb
ledger_sync-1.4.4 lib/ledger_sync/util/resource_converter/attribute_set.rb