Skip to content

Commit

Permalink
Use Mobility.locale in QueryBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
shioyama committed May 4, 2018
1 parent c73d0f1 commit 4d9528d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/mobility/plugins/active_record/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def #{Mobility.query_method}

module QueryExtension
def where!(opts, *rest)
QueryBuilder.build(self, opts, Mobility.locale) do |opts|
QueryBuilder.build(self, opts) do |opts|
opts ? super(opts) : super
end
end
Expand All @@ -36,17 +36,18 @@ def where(opts = :chain, *rest)

class WhereChain < ::ActiveRecord::QueryMethods::WhereChain
def not(opts, *rest)
QueryBuilder.build(@scope, opts, Mobility.locale, invert: true) do |opts|
QueryBuilder.build(@scope, opts, invert: true) do |opts|
opts ? super(opts) : super
end
end
end

module QueryBuilder
class << self
def build(scope, opts, locale, invert: false)
def build(scope, opts, invert: false)
return yield unless Hash === opts

locale = Mobility.locale
opts = opts.with_indifferent_access
keys = opts.keys.map &:to_s
predicates = []
Expand Down

0 comments on commit 4d9528d

Please sign in to comment.