Sha256: eb8a5688b48369522827c813160361d4bb8fab707b800f4a8617df06cb81dde7

Contents?: true

Size: 565 Bytes

Versions: 1

Compression:

Stored size: 565 Bytes

Contents

module AuthLh
  module RoleManagement
    def self.included(base)
      base.extend(ClassMethods)
    end

    def auth_role
      if @auth_role.nil?
        @auth_role = self.class.find_external(id)
      end

      @auth_role
    end

    def auth_role=(val)
      @auth_role = val
    end

    module ClassMethods
      def all_external
        @cached_roles ||= auth_api.get_roles
      end

      def find_external(id)
        all_external.find { |x| x.id == id.to_i }
      end

      def clear_cache!
        @cached_roles = nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auth-lh-1.3 lib/auth_lh/role_management.rb