Sha256: b619b12833ccdbb01f7c3432d0b56a4d2727150b7115df03b64b6c9a51b8b23c

Contents?: true

Size: 451 Bytes

Versions: 8

Compression:

Stored size: 451 Bytes

Contents

module MoneyS3
  module BaseElement
    EMPTY_ARRAY = []

    attr_accessor :raw

    def initialize(raw)
      @raw = raw
    end

    private

    def at(locator)
      return nil if raw.nil?

      raw[locator]
    end

    def all(locator)
      return [] if raw.nil?

      result = raw[locator]

      if result.is_a? Hash
        [result]
      elsif result.is_a? Array
        result
      else
        EMPTY_ARRAY
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
money_s3-0.1.8 lib/money_s3/base_element.rb
money_s3-0.1.7 lib/money_s3/base_element.rb
money_s3-0.1.6 lib/money_s3/base_element.rb
money_s3-0.1.5 lib/money_s3/base_element.rb
money_s3-0.1.4 lib/money_s3/base_element.rb
money_s3-0.1.3 lib/money_s3/base_element.rb
money_s3-0.1.1 lib/money_s3/base_element.rb
money_s3-0.1.0 lib/money_s3/base_element.rb