Class: AssignsHasManyThroughRelations::Configuration
- Inherits:
-
Object
- Object
- AssignsHasManyThroughRelations::Configuration
- Defined in:
- lib/assigns_has_many_through_relations/configuration.rb
Constant Summary collapse
- PROPERTIES =
%w[ auth_filter left_relation_scope selected_right_relation_scope available_right_relation_scope ]
Instance Method Summary collapse
-
#auth_filter(val = nil) ⇒ Object
Assign the name of a controller class method that you want to run for authorization e.g.
- #available_right_relation_scope(&block) ⇒ Object
-
#left_relation_scope(&block) ⇒ Object
Set a block that will return an ActiveRecord scope of the left side models.
-
#selected_right_relation_scope(&block) ⇒ Object
Set a block that will return an ActiveRecord scope of the selected left side model’s right side relations.
Instance Method Details
#auth_filter(val = nil) ⇒ Object
Assign the name of a controller class method that you want to run for authorization e.g. Cancan’s :load_and_authorize_resource, or a custom method you define in your ApplicationController
13 14 15 |
# File 'lib/assigns_has_many_through_relations/configuration.rb', line 13 def auth_filter(val = nil) @auth_filter ||= val end |
#available_right_relation_scope(&block) ⇒ Object
35 36 37 |
# File 'lib/assigns_has_many_through_relations/configuration.rb', line 35 def available_right_relation_scope(&block) @available_right_relation_scope ||= block_given? ? block : method(:default_available_right_relation_scope) end |
#left_relation_scope(&block) ⇒ Object
Set a block that will return an ActiveRecord scope of the left side models. the block will receive 2 arguments when it is called in the index action:
left_relation_class: class of the left side relation
user: the current user
21 22 23 |
# File 'lib/assigns_has_many_through_relations/configuration.rb', line 21 def left_relation_scope(&block) @left_relation_scope ||= block_given? ? block : method(:default_left_relation_scope) end |
#selected_right_relation_scope(&block) ⇒ Object
Set a block that will return an ActiveRecord scope of the selected left side model’s right side relations. The block will receive 2 arguments when it is called in the index action:
left_side_model: the selected left side model
right_relation_class: class of the right side relation
user: the current user
31 32 33 |
# File 'lib/assigns_has_many_through_relations/configuration.rb', line 31 def selected_right_relation_scope(&block) @selected_right_relation_scope ||= block_given? ? block : method(:default_selected_right_relation_scope) end |