Class: Spree::Ability
- Inherits:
-
Object
- Object
- Spree::Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/spree/ability.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
-
.register_ability(ability) ⇒ Object
Allows us to go beyond the standard cancan initialize method which makes it difficult for engines to modify the default
Ability
of an application. - .remove_ability(ability) ⇒ Object
Instance Method Summary collapse
-
#initialize(current_user) ⇒ Ability
constructor
A new instance of Ability.
Constructor Details
#initialize(current_user) ⇒ Ability
Returns a new instance of Ability.
27 28 29 30 31 32 33 |
# File 'app/models/spree/ability.rb', line 27 def initialize(current_user) @user = current_user || Spree.user_class.new alias_actions register_extension_abilities end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
13 14 15 |
# File 'app/models/spree/ability.rb', line 13 def user @user end |
Class Method Details
.register_ability(ability) ⇒ Object
Allows us to go beyond the standard cancan initialize method which makes it difficult for engines to modify the default Ability
of an application. The ability
argument must be a class that includes the CanCan::Ability
module. The registered ability should behave properly as a stand-alone class and therefore should be easy to test in isolation.
19 20 21 |
# File 'app/models/spree/ability.rb', line 19 def self.register_ability(ability) abilities.add(ability) end |
.remove_ability(ability) ⇒ Object
23 24 25 |
# File 'app/models/spree/ability.rb', line 23 def self.remove_ability(ability) abilities.delete(ability) end |