Class: ActiveRecord::Coders::Hstore
- Inherits:
-
Object
- Object
- ActiveRecord::Coders::Hstore
- Defined in:
- lib/activerecord-postgres-hstore/coder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #dump(obj) ⇒ Object
-
#initialize(default = nil) ⇒ Hstore
constructor
A new instance of Hstore.
- #load(hstore) ⇒ Object
Constructor Details
#initialize(default = nil) ⇒ Hstore
Returns a new instance of Hstore.
14 15 16 |
# File 'lib/activerecord-postgres-hstore/coder.rb', line 14 def initialize(default=nil) @default=default end |
Class Method Details
.dump(hstore) ⇒ Object
10 11 12 |
# File 'lib/activerecord-postgres-hstore/coder.rb', line 10 def self.dump(hstore) new({}).dump(hstore) end |
.load(hstore) ⇒ Object
6 7 8 |
# File 'lib/activerecord-postgres-hstore/coder.rb', line 6 def self.load(hstore) new({}).load(hstore) end |
Instance Method Details
#dump(obj) ⇒ Object
18 19 20 |
# File 'lib/activerecord-postgres-hstore/coder.rb', line 18 def dump(obj) obj.nil? ? (@default.nil? ? nil : to_hstore(@default)) : to_hstore(obj) end |
#load(hstore) ⇒ Object
22 23 24 |
# File 'lib/activerecord-postgres-hstore/coder.rb', line 22 def load(hstore) hstore.nil? ? @default : from_hstore(hstore) end |