Sha256: 5b84824905a0064abd0f6d55b1fea9c74b7b2ee9d0a8290d58719520545a061e

Contents?: true

Size: 627 Bytes

Versions: 6

Compression:

Stored size: 627 Bytes

Contents

module Scrivito

  class ObjDataFromHash < ObjData
    def initialize(hash, type_hash = {})
      @hash = hash.stringify_keys
      @type_hash = type_hash.stringify_keys
    end

    def raw_value_and_type_of(attribute_name)
      if has_custom_attribute?(attribute_name)
        [@hash[attribute_name], @type_hash[attribute_name]]
      end
    end

    def has_custom_attribute?(name)
      @hash.has_key?(name) || name == '_id'
    end

    def all_attributes
      @all_attributes ||= begin
        @hash.keys |
          INTERNAL_KEYS.to_a |
          SPECIAL_KEYS.to_a |
           %w[_id]
      end
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
scrivito_sdk-0.17.0 lib/scrivito/obj_data_from_hash.rb
scrivito_sdk-0.16.0 lib/scrivito/obj_data_from_hash.rb
scrivito_sdk-0.15.0 lib/scrivito/obj_data_from_hash.rb
scrivito_sdk-0.14.0 lib/scrivito/obj_data_from_hash.rb
scrivito_sdk-0.13.0 lib/scrivito/obj_data_from_hash.rb
scrivito_sdk-0.12.0 lib/scrivito/obj_data_from_hash.rb