Class: WinewooCore::Repositories::Mongo::Queries::InterproQuery

Inherits:
UserQuery show all
Defined in:
lib/winewoo_core/repositories/mongo/queries/interpro_query.rb

Instance Method Summary collapse

Methods inherited from UserQuery

#with_role

Methods inherited from WinewooQuery

#method_missing, #respond_to?, #respond_to_missing?

Constructor Details

#initializeInterproQuery

Returns a new instance of InterproQuery.



5
6
7
# File 'lib/winewoo_core/repositories/mongo/queries/interpro_query.rb', line 5

def initialize
  super User.where(user_roles: :interpro)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class WinewooCore::Repositories::Mongo::Queries::WinewooQuery

Instance Method Details

#without_wines(interpro_id) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/winewoo_core/repositories/mongo/queries/interpro_query.rb', line 10

def without_wines(interpro_id)
  wine_ids = WinewooCore::Repositories::Mongo::Queries::WineQuery
    .new
    .from_interpro(interpro_id)
    .map(&:interpro_id)

  @relation = @relation
    .where(:_id.nin => wine_ids)

  block_given? ?
    @relation.each { |user| yield user } :
    self
end