Class: ActiveRecord::Coders::Hstore

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord_postgres_hstore_core/coder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default = nil) ⇒ Hstore

Returns a new instance of Hstore.



12
13
14
# File 'lib/activerecord_postgres_hstore_core/coder.rb', line 12

def initialize(default=nil)
  @default=default
end

Class Method Details

.dump(hstore) ⇒ Object



8
9
10
# File 'lib/activerecord_postgres_hstore_core/coder.rb', line 8

def self.dump(hstore)
  new.dump(hstore)
end

.load(hstore) ⇒ Object



4
5
6
# File 'lib/activerecord_postgres_hstore_core/coder.rb', line 4

def self.load(hstore)
  new.load(hstore)
end

Instance Method Details

#dump(obj) ⇒ Object



16
17
18
# File 'lib/activerecord_postgres_hstore_core/coder.rb', line 16

def dump(obj)
  obj.nil? ? (@default.nil? ? nil : @default.to_hstore) : obj.to_hstore
end

#load(hstore) ⇒ Object



20
21
22
# File 'lib/activerecord_postgres_hstore_core/coder.rb', line 20

def load(hstore)
  hstore.nil? ? nil : hstore.from_hstore
end