Sha256: bf306eba26e99ae3f0f2f7f92eb6589145691fbae5e7bbc41b0b9d4fc6d3e7a5

Contents?: true

Size: 639 Bytes

Versions: 84

Compression:

Stored size: 639 Bytes

Contents

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
    end

  end
end

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
ddr-models-3.0.0.beta.22 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.21 lib/ddr/auth/ability_factory.rb
ddr-models-2.4.10 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.20 lib/ddr/auth/ability_factory.rb
ddr-models-2.4.9 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.18 lib/ddr/auth/ability_factory.rb
ddr-models-2.4.8 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.17 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.16 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.15 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.14 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.13 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.12 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.11 lib/ddr/auth/ability_factory.rb
ddr-models-2.4.7 lib/ddr/auth/ability_factory.rb
ddr-models-2.4.6 lib/ddr/auth/ability_factory.rb
ddr-models-2.4.5 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.10 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.9 lib/ddr/auth/ability_factory.rb
ddr-models-3.0.0.beta.8 lib/ddr/auth/ability_factory.rb