Class: Mobility::Backend::Sequel::Serialized::QueryMethods
- Inherits:
-
QueryMethods
- Object
- Module
- QueryMethods
- Mobility::Backend::Sequel::Serialized::QueryMethods
- Defined in:
- lib/mobility/backend/sequel/serialized/query_methods.rb
Instance Method Summary collapse
-
#initialize(attributes, **options) ⇒ QueryMethods
constructor
A new instance of QueryMethods.
Constructor Details
#initialize(attributes, **options) ⇒ QueryMethods
Returns a new instance of QueryMethods.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mobility/backend/sequel/serialized/query_methods.rb', line 4 def initialize(attributes, **) super attributes_extractor = @attributes_extractor cond_checker = @cond_checker = lambda do |cond| if i18n_keys = attributes_extractor.call(cond) raise ArgumentError, "You cannot query on mobility attributes translated with the Serialized backend (#{i18n_keys.join(", ")})." end end define_method :where do |*cond, &block| cond_checker.call(cond.first) || super(*cond, &block) end end |