Class: CanCan::ModelAdapters::Strategies::Subquery

Inherits:
Base
  • Object
show all
Defined in:
lib/cancan/model_adapters/strategies/subquery.rb

Instance Attribute Summary

Attributes inherited from Base

#adapter, #relation, #where_conditions

Instance Method Summary collapse

Methods inherited from Base

#aliased_table_name, #initialize, #quoted_aliased_table_name, #quoted_table_name

Constructor Details

This class inherits a constructor from CanCan::ModelAdapters::Strategies::Base

Instance Method Details

#build_joins_relation_subquery(where_conditions) ⇒ Object



9
10
11
12
13
14
# File 'lib/cancan/model_adapters/strategies/subquery.rb', line 9

def build_joins_relation_subquery(where_conditions)
  inner = model_class.unscoped do
    model_class.left_joins(joins).where(*where_conditions)
  end
  model_class.where(model_class.primary_key => inner)
end

#execute!Object



5
6
7
# File 'lib/cancan/model_adapters/strategies/subquery.rb', line 5

def execute!
  build_joins_relation_subquery(where_conditions)
end