Module: Queries::Concerns::Roles

Extended by:
ActiveSupport::Concern
Included in:
Queries::CollectingEvent::Autocomplete
Defined in:
lib/queries/concerns/roles.rb

Overview

Helpers for queries that reference Roles

Instance Method Summary collapse

Instance Method Details

#matching_person_cached(role = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/queries/concerns/roles.rb', line 23

def matching_person_cached(role = nil)
  return nil if no_terms? || !role
  k = table.name.classify.safe_constantize

  k.where(
    ::Role.joins(:person)
    .where(
      role_table[:role_object_id].eq(table[:id])
    .and(role_table[:role_object_type].eq(table.name.classify))
    .and(person_table[:cached].matches(start_and_end_wildcard))
    .and(role_table[:type].eq(role.capitalize))
  ).arel.exists
  )
end

#person_tableArel::Table

Returns:

  • (Arel::Table)


19
20
21
# File 'lib/queries/concerns/roles.rb', line 19

def person_table 
  ::Person.arel_table
end

#role_tableArel::Table

Returns:

  • (Arel::Table)


14
15
16
# File 'lib/queries/concerns/roles.rb', line 14

def role_table 
  ::Role.arel_table
end