Module: Walruz

Extended by:
Manager::AuthorizationQuery, Memoization
Defined in:
lib/walruz.rb,
lib/walruz/actor.rb,
lib/walruz/utils.rb,
lib/walruz/config.rb,
lib/walruz/policy.rb,
lib/walruz/manager.rb,
lib/walruz/subject.rb,
lib/walruz/exceptions.rb,
lib/walruz/core_ext/array.rb,
lib/walruz/more/pagination.rb,
lib/walruz/core_ext/memoization.rb,
lib/walruz/more/pagination/base.rb,
lib/walruz/more/pagination/view_helper.rb,
lib/walruz/more/pagination/will_paginate_collection.rb

Defined Under Namespace

Modules: Actor, CoreExt, Memoization, More, Subject, Utils Classes: ActionNotFound, AuthorizationActionsNotDefined, Config, Manager, NotAuthorized, Policy, PolicyHalted

Class Method Summary collapse

Methods included from Memoization

included

Methods included from Manager::AuthorizationQuery

authorize, authorize!, can?, satisfies, satisfies!, satisfies?

Class Method Details

.fetch_policy(policy_label) ⇒ Walruz::Policy

Returns a Walruz::Policy Class represented by the specified label

Examples:

Fetching a policy with label :actor_is_admin

Walruz.fetch_policy(:actor_is_admin) # => ActorIsAdmin

Parameters:

  • policy_label (Symbol)

    The label that identifies a policy

Returns:

Raises:



50
51
52
53
54
# File 'lib/walruz.rb', line 50

def self.fetch_policy(policy_label)
  policy_clz = Walruz.policies[policy_label]
  raise ActionNotFound.new(:policy_label, :label => policy_label) if policy_clz.nil?
  policy_clz
end

.policiesHash<Symbol, Walruz::Policy>

TODO:

Make this thread-safe

Holds all the policies declared on the system

Returns:

  • (Hash<Symbol, Walruz::Policy>)

    A hash of policies, each identified by it’s policy label



38
39
40
# File 'lib/walruz.rb', line 38

def self.policies
  Walruz::Policy.policies
end

.setup {|config| ... } ⇒ Object

Yields:

  • (config)


30
31
32
33
# File 'lib/walruz.rb', line 30

def self.setup
  config = Config.new
  yield config
end

.versionObject

Global Walruz Methods ###



24
25
26
27
28
# File 'lib/walruz.rb', line 24

def self.version
  require "yaml"
  version = YAML.load_file(File.dirname(__FILE__) + "/../VERSION.yml") 
  "%s.%s.%s" % [version[:major], version[:minor], version[:patch]]
end