lib/ddr/auth/ability_factory.rb in ddr-models-2.4.15 vs lib/ddr/auth/ability_factory.rb in ddr-models-2.4.16
- old
+ new
@@ -1,33 +1,10 @@
module Ddr::Auth
class AbilityFactory
- private_class_method :new
-
def self.call(user = nil, env = nil)
- new(user, env).call
- end
-
- attr_reader :auth_context
-
- delegate :anonymous?, :superuser?, to: :auth_context
-
- def initialize(user, env)
- @auth_context = AuthContextFactory.call(user, env)
- end
-
- def call
- if anonymous?
- AnonymousAbility.new(auth_context)
- elsif superuser?
- SuperuserAbility.new(auth_context)
- else
- default_ability.new(auth_context)
- end
- end
-
- def default_ability
- Ddr::Auth::default_ability.constantize
+ auth_context = AuthContextFactory.call(user, env)
+ auth_context.ability
end
end
end