Sha256: df4ce84dd2d28d6ac9b3f5bfd8fd9ef76b9bfbc08c502a86e3cdd950deee5676

Contents?: true

Size: 827 Bytes

Versions: 8

Compression:

Stored size: 827 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.grant *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

8 entries across 8 versions & 1 rubygems

Version Path
ddr-models-2.0.0.rc4 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.0.0.rc3 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.0.0.rc2 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.0.0.rc1 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.0.0.pre.5 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.0.0.pre.4 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.0.0.pre.3 lib/ddr/auth/legacy/legacy_authorization.rb
ddr-models-2.0.0.pre.2 lib/ddr/auth/legacy/legacy_authorization.rb