Module: Hstore::Document::ClassMethods
- Defined in:
- lib/hstore/document.rb
Instance Method Summary collapse
Instance Method Details
#field(name, options = {}) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/hstore/document.rb', line 175 def field(name, = {}) klass = [:type] default = [:default] _attr_defaults[name.to_s] = default unless default.nil? if klass.to_s.start_with?('Hstore::Fields::') serialize(name, klass) end define_accessors(name) end |
#from_hstore(data) ⇒ Object
168 169 170 171 172 173 |
# File 'lib/hstore/document.rb', line 168 def from_hstore(data) if ActiveRecord::VERSION::MAJOR < 4 data = PgHstore.load(data) end new(data, serialized: true) end |