Class: CanTango::Rules::UserRelation
- Inherits:
-
Object
- Object
- CanTango::Rules::UserRelation
- Defined in:
- lib/cantango/rules/user_relation.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#models ⇒ Object
readonly
Returns the value of attribute models.
-
#permit ⇒ Object
readonly
Returns the value of attribute permit.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #can(action) ⇒ Object
- #cannot(action) ⇒ Object
-
#initialize(attribute, permit, scope, *models, &block) ⇒ UserRelation
constructor
A new instance of UserRelation.
Methods included from RuleClass
Methods included from Adaptor
#adaptor_for, #get_adapter, #orm_map, #use_adaptor!
Constructor Details
#initialize(attribute, permit, scope, *models, &block) ⇒ UserRelation
Returns a new instance of UserRelation.
11 12 13 14 15 16 17 18 19 |
# File 'lib/cantango/rules/user_relation.rb', line 11 def initialize attribute, permit, scope, *models, &block @attribute = attribute @scope = scope @permit = permit @models = models check_models use_adaptor! self, user_scope end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
6 7 8 |
# File 'lib/cantango/rules/user_relation.rb', line 6 def attribute @attribute end |
#models ⇒ Object (readonly)
Returns the value of attribute models.
6 7 8 |
# File 'lib/cantango/rules/user_relation.rb', line 6 def models @models end |
#permit ⇒ Object (readonly)
Returns the value of attribute permit.
6 7 8 |
# File 'lib/cantango/rules/user_relation.rb', line 6 def permit @permit end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
6 7 8 |
# File 'lib/cantango/rules/user_relation.rb', line 6 def scope @scope end |
Instance Method Details
#can(action) ⇒ Object
21 22 23 24 25 |
# File 'lib/cantango/rules/user_relation.rb', line 21 def can(action) models.each do |model| rules << rule_class.new(true, action, model, nil, condition_block(model)) end end |
#cannot(action) ⇒ Object
27 28 29 30 31 |
# File 'lib/cantango/rules/user_relation.rb', line 27 def cannot(action) models.each do |model| rules << rule_class.new(false, action, model, nil, condition_block(model)) end end |