Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/active_record_hstore_serializer/hash.rb
Instance Method Summary collapse
-
#from_hstore ⇒ Object
If the method from_hstore is called in a Hash, it just returns self.
- #to_hstore ⇒ Object
Instance Method Details
#from_hstore ⇒ Object
If the method from_hstore is called in a Hash, it just returns self.
23 24 25 |
# File 'lib/active_record_hstore_serializer/hash.rb', line 23 def from_hstore self end |
#to_hstore ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/active_record_hstore_serializer/hash.rb', line 3 def to_hstore return "" if empty? map { |idx, val| iv = [idx,val].map { |_| e = _.to_s.gsub(/"/, '\"') if _.nil? 'NULL' elsif e =~ /[,\s=>]/ || e.blank? '"%s"' % e else e end } "%s=>%s" % iv } * "," end |