Sha256: b404b0670b4c763a82e4627ac3fa4213681e456ecc99589dc533009bba64bdb1

Contents?: true

Size: 436 Bytes

Versions: 3

Compression:

Stored size: 436 Bytes

Contents

class Hash

  # Generates a single quoted hstore string format. This is the format used
  # to insert or update stuff in the database.
  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

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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-postgres-hstore-0.1.0 lib/activerecord-postgres-hstore/hash.rb
activerecord-postgres-hstore-0.0.4 lib/activerecord-postgres-hstore/hash.rb
activerecord-postgres-hstore-0.0.3 lib/activerecord-postgres-hstore/hash.rb