Class: ActiveRecord::TypedStore::Coder

Inherits:
Store::IndifferentCoder
  • Object
show all
Defined in:
lib/active_record/typed_store/coder.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.as_indifferent_hash(obj) ⇒ Object



13
14
15
16
# File 'lib/active_record/typed_store/coder.rb', line 13

def as_indifferent_hash(obj)
  return obj if obj.is_a?(@store_class)
  @store_class.new(obj)
end

.create(store_class) ⇒ Object



7
8
9
10
11
# File 'lib/active_record/typed_store/coder.rb', line 7

def create(store_class)
  Class.new(self) do
    @store_class = store_class
  end
end

Instance Method Details

#dump(obj) ⇒ Object



22
23
24
# File 'lib/active_record/typed_store/coder.rb', line 22

def dump(obj)
  @coder.dump(obj.try(:to_hash) || {})
end