Class: FatModelAuth::CannedGateKeeper
- Inherits:
-
Object
- Object
- FatModelAuth::CannedGateKeeper
show all
- Defined in:
- lib/fat_model_auth/canned_gate_keeper.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of CannedGateKeeper.
17
18
19
20
|
# File 'lib/fat_model_auth/canned_gate_keeper.rb', line 17
def initialize(params)
@map = {}
add_rules(params)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *_args) ⇒ Object
26
27
28
29
30
|
# File 'lib/fat_model_auth/canned_gate_keeper.rb', line 26
def method_missing(method, *_args)
raise NoMethodError, "undefined method allows(user).#{method} for #{self.class}" unless @map.key?(method)
@map[method].call
end
|
Class Method Details
.allows(action) ⇒ Object
5
6
7
|
# File 'lib/fat_model_auth/canned_gate_keeper.rb', line 5
def self.allows(action)
new(action => true)
end
|
.build(params) ⇒ Object
13
14
15
|
# File 'lib/fat_model_auth/canned_gate_keeper.rb', line 13
def self.build(params)
new(params)
end
|
.denies(action) ⇒ Object
9
10
11
|
# File 'lib/fat_model_auth/canned_gate_keeper.rb', line 9
def self.denies(action)
new(action => false)
end
|
Instance Method Details
#allows(_user) ⇒ Object
22
23
24
|
# File 'lib/fat_model_auth/canned_gate_keeper.rb', line 22
def allows(_user)
self
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
32
33
34
|
# File 'lib/fat_model_auth/canned_gate_keeper.rb', line 32
def respond_to_missing?(method, include_private = false)
@map.key?(method) || super
end
|