Module: Arrthorizer

Defined in:
lib/arrthorizer/role.rb,
lib/arrthorizer.rb,
lib/arrthorizer/group.rb,
lib/arrthorizer/rails.rb,
lib/arrthorizer/roles.rb,
lib/arrthorizer/rspec.rb,
lib/arrthorizer/context.rb,
lib/arrthorizer/version.rb,
lib/arrthorizer/registry.rb,
lib/arrthorizer/privilege.rb,
lib/arrthorizer/permission.rb,
lib/arrthorizer/context_role.rb,
lib/arrthorizer/rspec/matchers.rb,
lib/arrthorizer/context_builder.rb,
lib/arrthorizer/rails/configuration.rb,
lib/arrthorizer/arrthorizer_exception.rb,
lib/arrthorizer/rails/controller_action.rb,
lib/arrthorizer/rails/controller_concern.rb,
lib/arrthorizer/rails/controller_configuration.rb,
lib/arrthorizer/rails/controller_context_builder.rb,
lib/generators/arrthorizer/install/install_generator.rb

Overview

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’

Defined Under Namespace

Modules: Generators, Permission, RSpec, Rails Classes: ArrthorizerException, Context, ContextBuilder, ContextRole, ContextRoleGenerator, Everybody, Group, LoggedInUser, Nobody, Privilege, Registry, Role

Constant Summary collapse

VERSION =
"0.4.1"

Class Method Summary collapse

Class Method Details

.check_group_membership_using(object) ⇒ Object

Inject a dependency for Arrthorizer’s Groups feature. The provided object needs to be able to respond_to :is_member_of? The is_member_of? function is expected to return a boolean-like object which represents whether or not the user is a member of the provided Group



36
37
38
39
40
41
42
# File 'lib/arrthorizer.rb', line 36

def self.check_group_membership_using(object)
  if object.respond_to?(:is_member_of?)
    @membership_service = object
  else
    raise "Arrthorizer cannot check role membership using #{object.inspect}"
  end
end

.configure(&block) ⇒ Object



26
27
28
# File 'lib/arrthorizer.rb', line 26

def self.configure(&block)
  self.instance_eval(&block)
end

.Context(contents) ⇒ Object



74
75
76
77
78
# File 'lib/arrthorizer/context.rb', line 74

def Context(contents)
  Context.build(contents)
rescue NoMethodError
  raise Arrthorizer::Context::ConversionError, "Can't convert #{contents} to an Arrthorizer::Context"
end

.membership_serviceObject



44
45
46
# File 'lib/arrthorizer.rb', line 44

def self.membership_service
  @membership_service
end