Class: Abilities::Proxy
- Inherits:
-
Object
show all
- Defined in:
- lib/abilities/proxy.rb
Instance Method Summary
collapse
Constructor Details
#initialize(definitions, &block) ⇒ Proxy
Returns a new instance of Proxy.
4
5
6
7
|
# File 'lib/abilities/proxy.rb', line 4
def initialize(definitions, &block)
@definitions = definitions
instance_eval &block
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
17
18
19
|
# File 'lib/abilities/proxy.rb', line 17
def method_missing(name, *args, &block)
@definitions.user.send name, *args, &block
end
|
Instance Method Details
#can(actions, resources, &block) ⇒ Object
9
10
11
|
# File 'lib/abilities/proxy.rb', line 9
def can(actions, resources, &block)
@definitions.add actions, resources, (block_given? ? block : true)
end
|
#cannot(actions, resources, &block) ⇒ Object
13
14
15
|
# File 'lib/abilities/proxy.rb', line 13
def cannot(actions, resources, &block)
@definitions.add actions, resources, (block_given? ? block : false)
end
|