module Consul::Controller::ClassMethods
Public Instance Methods
current_power_initializer()
click to toggle source
# File lib/consul/controller.rb, line 20 def current_power_initializer @current_power_initializer || (superclass.respond_to?(:current_power_initializer) && superclass.current_power_initializer) end
current_power_initializer=(initializer)
click to toggle source
# File lib/consul/controller.rb, line 24 def current_power_initializer=(initializer) @current_power_initializer = initializer end
Private Instance Methods
consul_power_args()
click to toggle source
On first access we inherit .consul_power_args from our ancestor classes. We also copy inherited args so we don't change our parent's .consul_power_args
# File lib/consul/controller.rb, line 73 def consul_power_args unless @consul_power_args_initialized if superclass && superclass.respond_to?(:consul_power_args, true) @consul_power_args = superclass.send(:consul_power_args).dup else @consul_power_args = [] end @consul_power_args_initialized = true end @consul_power_args end
current_power(&initializer)
click to toggle source
# File lib/consul/controller.rb, line 39 def current_power(&initializer) self.current_power_initializer = initializer Util.around_action(self, :with_current_power) if respond_to?(:helper_method) helper_method :current_power end end
power(*args)
click to toggle source
# File lib/consul/controller.rb, line 48 def power(*args) guard = Consul::Guard.new(*args) # One .power directive will skip the check for all actions, even # if that .power directive has :only or :except options. skip_power_check # Store arguments for testing consul_power_args << args Util.before_action(self, guard.filter_options) do |controller| guard.ensure!(controller, controller.action_name) end if guard.direct_access_method define_method guard.direct_access_method do guard.power_value(self, action_name) end private guard.direct_access_method end end
require_power_check(options = {})
click to toggle source
# File lib/consul/controller.rb, line 30 def require_power_check(options = {}) Util.before_action(self, :unchecked_power, options) end
skip_power_check(options = {})
click to toggle source
This is badly named, since it doesn't actually skip the :check_power filter
# File lib/consul/controller.rb, line 35 def skip_power_check(options = {}) Util.skip_before_action(self, :unchecked_power, options) end