Class: ActiveRecord::QueryMethods::ArrayChain
- Inherits:
-
StoreChain
- Object
- StoreChain
- ActiveRecord::QueryMethods::ArrayChain
- Defined in:
- lib/pgrel/active_record/store_chain/array_chain.rb
Overview
Store chain for array columns.
Instance Attribute Summary
Attributes inherited from StoreChain
#quoted_store_name, #store_name
Instance Method Summary collapse
-
#overlap(*vals) ⇒ Object
Whether the array overlaps provided array.
Methods inherited from StoreChain
#contained, #contains, #initialize, #not, #where
Constructor Details
This class inherits a constructor from ActiveRecord::QueryMethods::StoreChain
Instance Method Details
#overlap(*vals) ⇒ Object
Whether the array overlaps provided array.
Example
Model.create!(name: 'first', store: ['b', 'c'])
Model.create!(name: 'second', store: ['a', 'b'])
Model.store(:store).overlap('c').all #=> [Model(name: 'first', ...)]
Model.store(:store).overlap(['b']).size #=> 2
15 16 17 |
# File 'lib/pgrel/active_record/store_chain/array_chain.rb', line 15 def overlap(*vals) update_scope "#{quoted_store_name} && #{type_cast(vals.flatten)}" end |