class Shoulda::Matchers::ActionController::PermitMatcher::ParametersDoubleRegistry
@private
Constants
- TOP_LEVEL
Attributes
Public Class Methods
Source
# File lib/shoulda/matchers/action_controller/permit_matcher.rb, line 379 def initialize(params) @params = params @double_collections_by_parameter_name = {} end
Source
# File lib/shoulda/matchers/action_controller/permit_matcher.rb, line 375 def self.permitted_parameter_names_within(double_collection) double_collection.calls_to(:permit).map(&:args).flatten end
Public Instance Methods
Source
# File lib/shoulda/matchers/action_controller/permit_matcher.rb, line 388 def permitted_parameter_names(args = {}) subparameter_name = args.fetch(:for, TOP_LEVEL) if double_collections_by_parameter_name.key?(subparameter_name) self.class.permitted_parameter_names_within( double_collections_by_parameter_name[subparameter_name], ) else [] end end
Source
# File lib/shoulda/matchers/action_controller/permit_matcher.rb, line 384 def register register_double_for_permit_against(params, TOP_LEVEL) end
Private Instance Methods
Source
# File lib/shoulda/matchers/action_controller/permit_matcher.rb, line 406 def register_double_for_permit_against(params, subparameter_name) klass = params.singleton_class double_collection = Doublespeak.double_collection_for(klass) register_double_for_permit_on(double_collection) register_double_for_require_on(double_collection) double_collections_by_parameter_name[subparameter_name] = double_collection end
Source
# File lib/shoulda/matchers/action_controller/permit_matcher.rb, line 417 def register_double_for_permit_on(double_collection) double_collection.register_proxy(:permit) end
Source
# File lib/shoulda/matchers/action_controller/permit_matcher.rb, line 421 def register_double_for_require_on(double_collection) double_collection.register_proxy(:require).to_return do |call| params = call.return_value subparameter_name = call.args.first register_double_for_permit_against(params, subparameter_name) end end