Class: FindByTagsStrategy
- Inherits:
-
QueryStrategy
- Object
- QueryStrategy
- FindByTagsStrategy
- Defined in:
- lib/needle_in_a_haystack/strategies/find_by_tags_strategy.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(model, tags) ⇒ FindByTagsStrategy
constructor
A new instance of FindByTagsStrategy.
Constructor Details
#initialize(model, tags) ⇒ FindByTagsStrategy
Returns a new instance of FindByTagsStrategy.
2 3 4 5 6 |
# File 'lib/needle_in_a_haystack/strategies/find_by_tags_strategy.rb', line 2 def initialize(model, ) super() @model = model @tags = end |
Instance Method Details
#execute ⇒ Object
8 9 10 |
# File 'lib/needle_in_a_haystack/strategies/find_by_tags_strategy.rb', line 8 def execute @model.joins(:haystack_tags).where(haystack_tags: { id: @tags.map(&:id) }) end |