Sha256: 479f0140560a2b9caf234e09f9aa88b05b2718cf5deab415bdf320046dcad0f0

Contents?: true

Size: 631 Bytes

Versions: 13

Compression:

Stored size: 631 Bytes

Contents

require 'singleton'

##
# This is the superclass for all ContextRoles that the application may contain.
# A ContextRole is a role that a User may or may not have, depending on the
# current context. This can be things like 'the author of a certain post' or 'a
# member of the current group'
module Arrthorizer
  class ContextRole < Role
    include Singleton

    def to_key
      self.class.to_key
    end

    def self.to_key
      name
    end

    def self.applies_to_user?(*args)
      instance.applies_to_user?(*args)
    end

    def self.inherited(klass)
      super

      Role.register(klass.instance)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
arrthorizer-0.4.2 lib/arrthorizer/context_role.rb
arrthorizer-0.4.1 lib/arrthorizer/context_role.rb
arrthorizer-0.3.2 lib/arrthorizer/context_role.rb
arrthorizer-0.3.1 lib/arrthorizer/context_role.rb
arrthorizer-0.3.0 lib/arrthorizer/context_role.rb
arrthorizer-0.2.1 lib/arrthorizer/context_role.rb
arrthorizer-0.2.0 lib/arrthorizer/context_role.rb
arrthorizer-0.1.3 lib/arrthorizer/context_role.rb
arrthorizer-0.1.2 lib/arrthorizer/context_role.rb
arrthorizer-0.1.1 lib/arrthorizer/context_role.rb
arrthorizer-0.1.0 lib/arrthorizer/context_role.rb
arrthorizer-0.1.0.pre2 lib/arrthorizer/context_role.rb
arrthorizer-0.1.0.pre lib/arrthorizer/context_role.rb