Class: CouchbaseOrm::Types::Hash
- Inherits:
-
ActiveModel::Type::Value
- Object
- ActiveModel::Type::Value
- CouchbaseOrm::Types::Hash
- Defined in:
- lib/couchbase-orm/types/hash.rb
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/couchbase-orm/types/hash.rb', line 6 def cast(value) return nil if value.nil? return value if value.is_a?(ActiveSupport::HashWithIndifferentAccess) return value.with_indifferent_access if value.is_a?(::Hash) raise ArgumentError.new("Hash: #{value.inspect} (#{value.class}) is not supported for cast") end |
#serialize(value) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/couchbase-orm/types/hash.rb', line 14 def serialize(value) return nil if value.nil? return value.as_json if value.is_a?(ActiveSupport::HashWithIndifferentAccess) return value.with_indifferent_access.as_json if value.is_a?(::Hash) raise ArgumentError.new("Hash: #{value.inspect} (#{value.class}) is not supported for serialize") end |