lib/mobility/backends/sequel/hstore/query_methods.rb in mobility-0.5.1 vs lib/mobility/backends/sequel/hstore/query_methods.rb in mobility-0.6.0

- old
+ new

@@ -4,24 +4,31 @@ Sequel.extension :pg_hstore, :pg_hstore_ops module Mobility module Backends - class Sequel::Hstore::QueryMethods < Sequel::QueryMethods - include Sequel::PgQueryMethods + module Sequel + class Hstore::QueryMethods < QueryMethods + include PgQueryMethods - private + def matches(key, locale) + build_op(key)[locale] + end - def matches(key, value, locale) - build_op(key)[locale] =~ value.to_s - end + def exists(key, locale) + build_op(key).has_key?(locale) + end - def has_locale(key, locale) - build_op(key).has_key?(locale) - end + def quote(value) + value && value.to_s + end - def build_op(key) - ::Sequel.hstore_op(key) + private + + def build_op(key) + ::Sequel.hstore_op(column_name(key)) + end end + Hstore.private_constant :QueryMethods end end end