Module: Queries::Concerns::Polymorphic

Extended by:
ActiveSupport::Concern
Defined in:
lib/queries/concerns/polymorphic.rb

Overview

Used to handle params from shallow routes like /otus/123/data_attributes These translate to ‘otu_id: 123`. !! Only include in annotating filters.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.and_clausesObject



44
45
46
# File 'lib/queries/concerns/polymorphic.rb', line 44

def self.and_clauses
  [ :polymorphic_id_facet ]
end

.paramsObject



7
8
9
10
11
12
# File 'lib/queries/concerns/polymorphic.rb', line 7

def self.params
  [ 
#     :polymorphic_id,
#     :polymorphic_type
  ] 
end

Instance Method Details

#polymorphic_id_facetObject



39
40
41
42
# File 'lib/queries/concerns/polymorphic.rb', line 39

def polymorphic_id_facet
  return nil if polymorphic_id.blank?
  table[referenced_klass.annotator_id].eq(polymorphic_id).and(table[referenced_klass.annotator_type].eq(polymorphic_type))
end