Class: Consul::Guard
- Inherits:
-
Object
- Object
- Consul::Guard
- Defined in:
- lib/consul/guard.rb
Defined Under Namespace
Classes: ActionMap
Instance Method Summary collapse
- #direct_access_method ⇒ Object
- #ensure!(controller, action_name) ⇒ Object
- #filter_options ⇒ Object
-
#initialize(*args) ⇒ Guard
constructor
A new instance of Guard.
- #power_value(controller, action_name) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Guard
Returns a new instance of Guard.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/consul/guard.rb', line 49 def initialize(*args) args_copy = args.dup @options = args_copy. default_power = args_copy.shift # might be nil custom_action_mappings = @options[:map] if @options[:crud] @map = ActionMap.crud(@options[:crud], custom_action_mappings) else @map = ActionMap.new(default_power, custom_action_mappings) end end |
Instance Method Details
#direct_access_method ⇒ Object
78 79 80 |
# File 'lib/consul/guard.rb', line 78 def direct_access_method @options[:as] end |
#ensure!(controller, action_name) ⇒ Object
70 71 72 |
# File 'lib/consul/guard.rb', line 70 def ensure!(controller, action_name) repository(controller).include_power!(*power_name_with_context(controller, action_name)) end |
#filter_options ⇒ Object
74 75 76 |
# File 'lib/consul/guard.rb', line 74 def @options.slice(:except, :only) end |
#power_value(controller, action_name) ⇒ Object
66 67 68 |
# File 'lib/consul/guard.rb', line 66 def power_value(controller, action_name) repository(controller).send(*power_name_with_context(controller, action_name)) end |