Sha256: ab37ae9bf0c76e4d43040ac6b5614d8c6a0c316457454adefe4fbfe8929c52ad

Contents?: true

Size: 576 Bytes

Versions: 8

Compression:

Stored size: 576 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(code)
      end

      @auth_role
    end

    def auth_role=(val)
      @auth_role = val
    end

    module ClassMethods
      def all_external
        @cached_roles ||= AuthLh::Api.get_roles
      end

      def find_external(code)
        all_external.find { |x| x.code == code.to_s }
      end

      def clear_cache!
        @cached_roles = nil
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
auth-lh-0.16.0 lib/auth_lh/role_management.rb
auth-lh-0.15.0 lib/auth_lh/role_management.rb
auth-lh-0.14.2 lib/auth_lh/role_management.rb
auth-lh-0.14.1 lib/auth_lh/role_management.rb
auth-lh-0.14.0 lib/auth_lh/role_management.rb
auth-lh-0.13.1 lib/auth_lh/role_management.rb
auth-lh-0.13.0 lib/auth_lh/role_management.rb
auth-lh-0.12.1 lib/auth_lh/role_management.rb