lib/consul/controller.rb in consul-0.2.3 vs lib/consul/controller.rb in consul-0.3.0

- old
+ new

@@ -49,29 +49,38 @@ filter_options = options.slice(:except, :only) skip_power_check filter_options power_method = options[:power] || :current_power + actions_map = (options[:map] || {}) + if crud_resource = options[:crud] + default_power ||= crud_resource + actions_map[[:show, :index]] = crud_resource.to_sym + actions_map[[:new, :create]] = "creatable_#{crud_resource}".to_sym + actions_map[[:edit, :update]] = "updatable_#{crud_resource}".to_sym + actions_map[:destroy] = "destroyable_#{crud_resource}".to_sym + end + direct_access_method = options[:as] # Store arguments for testing @consul_power_args = args before_filter :check_power, filter_options private define_method :check_power do - send(power_method).include!(power_for_action) + send(power_method).include!(power_method_for_action) end define_method direct_access_method do - send(power_method).send(power_for_action) + send(power_method).send(power_method_for_action) end if direct_access_method - define_method :power_for_action do + define_method :power_method_for_action do key = actions_map.keys.detect do |actions| Array(actions).collect(&:to_s).include?(action_name) end if key actions_map[key]