Sha256: 207643471af5e58569dafe682ec8ea02bdcccae16ee95c6d869e31282be9cdad

Contents?: true

Size: 829 Bytes

Versions: 49

Compression:

Stored size: 829 Bytes

Contents

require "delegate"

module Ddr::Auth
  class LegacyAuthorization < SimpleDelegator

    def to_roles
      sources.map(&:to_roles).reduce(&:merge)
    end

    def clear
      sources.each(&:clear)
    end

    def clear?
      sources.all? { |auth| auth.source.empty? }
    end

    def migrate
      migrated = inspect
      roles.replace *to_roles
      clear
      ["LEGACY AUTHORIZATION DATA", migrated, "ROLES", roles.serialize.inspect].join("\n\n")
    end

    def inspect
      sources.map { |auth| auth.inspect }.join("\n")
    end

    private

    def sources
      wrappers.map { |wrapper| wrapper.new(self) }
    end

    def wrappers
      classes = [ LegacyPermissions, LegacyRoles ]
      if respond_to? :default_permissions
        classes << LegacyDefaultPermissions
      end
      classes
    end

  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
ddr-models-2.6.2 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.6.1 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.6.0 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.6.0.rc4 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.6.0.rc3 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.6.0.rc2 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.6.0.rc1 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.5.3 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.5.2 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.5.1 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.5.0 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.5.0.rc1 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.4.16 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.4.15 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.4.14 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.4.13 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.4.12 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.4.11 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.4.10 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.4.9 lib/ddr/auth/legacy/legacy_authorization.rb