Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord-postgres-hstore/hash.rb

Instance Method Summary collapse

Instance Method Details

#from_hstoreObject

If the method from_hstore is called in a Hash, it just returns self.



12
13
14
# File 'lib/activerecord-postgres-hstore/hash.rb', line 12

def from_hstore
  self
end

#to_hstoreObject

Generates a single quoted hstore string format. This is the format used to insert or update stuff in the database.



5
6
7
8
9
# File 'lib/activerecord-postgres-hstore/hash.rb', line 5

def to_hstore
  return "''" if empty?
  #@todo DIOGO! Check security issues with this quoting pleaz
  map{|idx,val| "('#{idx}'=>'#{val.to_s.gsub(/'/,"''")}')"  }.join(' || ')
end