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

- old
+ new

@@ -4,24 +4,31 @@ Sequel.extension :pg_json, :pg_json_ops module Mobility module Backends - class Sequel::Json::QueryMethods < Sequel::QueryMethods - include Sequel::PgQueryMethods + module Sequel + class Json::QueryMethods < QueryMethods + include PgQueryMethods - private + def matches(key, locale) + build_op(key).get_text(locale) + end - def matches(key, value, locale) - build_op(key).get_text(locale) =~ value.to_s - end + def exists(key, locale) + matches(key, locale) !~ nil + end - def has_locale(key, locale) - build_op(key).get_text(locale) !~ nil - end + def quote(value) + value && value.to_s + end - def build_op(key) - ::Sequel.pg_json_op(key) + private + + def build_op(key) + ::Sequel.pg_json_op(column_name(key)) + end end + Json.private_constant :QueryMethods end end end