Class: Ddr::Auth::AbilityFactory
- Inherits:
-
Object
- Object
- Ddr::Auth::AbilityFactory
- Defined in:
- lib/ddr/auth/ability_factory.rb
Instance Attribute Summary collapse
-
#auth_context ⇒ Object
readonly
Returns the value of attribute auth_context.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #default_ability ⇒ Object
-
#initialize(user, env) ⇒ AbilityFactory
constructor
A new instance of AbilityFactory.
Constructor Details
#initialize(user, env) ⇒ AbilityFactory
Returns a new instance of AbilityFactory.
14 15 16 |
# File 'lib/ddr/auth/ability_factory.rb', line 14 def initialize(user, env) @auth_context = AuthContextFactory.call(user, env) end |
Instance Attribute Details
#auth_context ⇒ Object (readonly)
Returns the value of attribute auth_context.
10 11 12 |
# File 'lib/ddr/auth/ability_factory.rb', line 10 def auth_context @auth_context end |
Class Method Details
.call(user = nil, env = nil) ⇒ Object
6 7 8 |
# File 'lib/ddr/auth/ability_factory.rb', line 6 def self.call(user = nil, env = nil) new(user, env).call end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/ddr/auth/ability_factory.rb', line 18 def call if anonymous? AnonymousAbility.new(auth_context) elsif superuser? SuperuserAbility.new(auth_context) else default_ability.new(auth_context) end end |