Sha256: ec64affd8a8204334931dc13d9e8000c90a8c0c728c0fe9ecb7d974e1e749b04

Contents?: true

Size: 587 Bytes

Versions: 32

Compression:

Stored size: 587 Bytes

Contents

module Tdc
  #
  # Knows how to transform the result of calling the TestDefinitionReader#read method from an Array
  # of Hash instances into an Array of ActiveSupport::HashWithIndifferentAccess instances.
  #
  module WithIndifferentAccessDecorator
    def read(*path_elements)
      definitions = super

      raise Tdc::FatalError, "Use 'with_indifferent_access' only for an Array" unless definitions.is_a?(Array)

      definitions.map do |definition|
        definition.is_a?(Hash) ? ActiveSupport::HashWithIndifferentAccess.new(definition) : definition
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
tdc-1.1 lib/tdc/with_indifferent_access_decorator.rb
tdc-1.0 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.6.2 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.6.1 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.6.0 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.5.0 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.4.7 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.4.6.1 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.4.6 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.4.4.1 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.4.4 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.4.3.1 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.4.3 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.4.2 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.4.1 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.4.0 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.3.9 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.3.8 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.3.7 lib/tdc/with_indifferent_access_decorator.rb
tdc-0.3.6.1 lib/tdc/with_indifferent_access_decorator.rb