Module: Aclatraz

Extended by:
Helpers
Defined in:
lib/aclatraz.rb,
lib/aclatraz/acl.rb,
lib/aclatraz/guard.rb,
lib/aclatraz/store.rb,
lib/aclatraz/helpers.rb,
lib/aclatraz/suspect.rb,
lib/aclatraz/store/riak.rb,
lib/aclatraz/store/mongo.rb,
lib/aclatraz/store/redis.rb,
lib/aclatraz/store/cassandra.rb

Defined Under Namespace

Modules: Guard, Helpers, Store, Suspect Classes: ACL, AccessDenied, InvalidPermission, InvalidStore, InvalidSuspect, StoreNotInitialized, UndefinedAccessControlList

Class Method Summary collapse

Methods included from Helpers

camelize, pack, suspect_id, unpack

Class Method Details

.aclObject

Access control lists fof all classes protected by Aclatraz.



50
51
52
# File 'lib/aclatraz.rb', line 50

def self.acl
  @acl ||= {}
end

.init(store, *args) ⇒ Object

Initialize Aclatraz system with given datastore.

Aclatraz.init :redis, "redis://localhost:6379/0"
Aclatraz.init :tokyocabinet, "./permissions.tch"
Aclatraz.init MyCustomDatastore, :option => 1 # ...


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

def self.init(store, *args)
  store = eval("Aclatraz::Store::#{camelize(store.to_s)}") unless store.is_a?(Class)
  @store = store.new(*args)
rescue NameError
  raise InvalidStore, "The #{store.inspect} ACL store is not defined!"
end

.storeObject

Returns current datastore object, or raises StoreNotInitialized when init method wasn’t called before.



45
46
47
# File 'lib/aclatraz.rb', line 45

def self.store
  @store or raise StoreNotInitialized, "ACLatraz is not initialized!"
end