Class: CanTango::Api::Ability::Relation
- Inherits:
-
Object
- Object
- CanTango::Api::Ability::Relation
- Includes:
- CanTango::Adaptor, CanCan::RuleClass
- Defined in:
- lib/cantango/api/ability/relation.rb
Instance Attribute Summary collapse
-
#abil ⇒ Object
readonly
Returns the value of attribute abil.
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#models ⇒ Object
readonly
Returns the value of attribute models.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #can(action) ⇒ Object
- #cannot(action) ⇒ Object
-
#initialize(attribute, ability, scope, *models, &block) ⇒ Relation
constructor
A new instance of Relation.
Constructor Details
#initialize(attribute, ability, scope, *models, &block) ⇒ Relation
Returns a new instance of Relation.
12 13 14 15 16 17 18 19 20 |
# File 'lib/cantango/api/ability/relation.rb', line 12 def initialize attribute, ability, scope, *models, &block @attribute = attribute @abil = ability @scope = scope @models = models check_models use_adaptor! self, user_scope end |
Instance Attribute Details
#abil ⇒ Object (readonly)
Returns the value of attribute abil.
7 8 9 |
# File 'lib/cantango/api/ability/relation.rb', line 7 def abil @abil end |
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
7 8 9 |
# File 'lib/cantango/api/ability/relation.rb', line 7 def attribute @attribute end |
#models ⇒ Object (readonly)
Returns the value of attribute models.
7 8 9 |
# File 'lib/cantango/api/ability/relation.rb', line 7 def models @models end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
7 8 9 |
# File 'lib/cantango/api/ability/relation.rb', line 7 def scope @scope end |
Instance Method Details
#can(action) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/cantango/api/ability/relation.rb', line 24 def can(action) models.each do |model| rules << rule_class.new(true, action, model, nil, condition_block(model)) end self end |
#cannot(action) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/cantango/api/ability/relation.rb', line 31 def cannot(action) models.each do |model| rules << rule_class.new(false, action, model, nil, condition_block(model)) end self end |