class Querkle::Role
Public Class Methods
compile(entity)
click to toggle source
# File lib/querkle/role.rb, line 3 def self.compile(entity) role = @roles.find { |r| r.valid?(entity) } role.new(entity) end
register(role)
click to toggle source
# File lib/querkle/role.rb, line 8 def self.register(role) @roles ||= [] @roles << role end
valid?(entity)
click to toggle source
# File lib/querkle/role.rb, line 13 def self.valid?(entity) false end
Public Instance Methods
Private Instance Methods
allow_all!()
click to toggle source
# File lib/querkle/role.rb, line 39 def allow_all! @all_allowed = true end
can(action)
click to toggle source
# File lib/querkle/role.rb, line 35 def can(action) features[action] = true end
can?(action)
click to toggle source
# File lib/querkle/role.rb, line 23 def can?(action) if @all_allowed true else features[action] end end
features()
click to toggle source
# File lib/querkle/role.rb, line 31 def features @_features ||= Hash.new(false) end