Class: JsonApiFilter::AutoJoin

Inherits:
Object
  • Object
show all
Defined in:
lib/json_api_filter/auto_join.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, association_name) ⇒ AutoJoin

Returns a new instance of AutoJoin.

Parameters:

  • scope (ActiveRecord::Base, ActiveRecord_Relation)
  • association_name (String, Symbol)


8
9
10
11
# File 'lib/json_api_filter/auto_join.rb', line 8

def initialize(scope, association_name)
  @association_name = association_name
  @scope = scope
end

Instance Attribute Details

#association_nameObject (readonly)

Returns the value of attribute association_name.



4
5
6
# File 'lib/json_api_filter/auto_join.rb', line 4

def association_name
  @association_name
end

#scopeObject (readonly)

Returns the value of attribute scope.



4
5
6
# File 'lib/json_api_filter/auto_join.rb', line 4

def scope
  @scope
end

Instance Method Details

#predicateObject



13
14
15
# File 'lib/json_api_filter/auto_join.rb', line 13

def predicate
  scope.joins(association_name.to_sym)
end