Class: Shoulda::Matchers::ActionController::PermitMatcher::ParametersDoubleRegistry
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActionController::PermitMatcher::ParametersDoubleRegistry
- Defined in:
- lib/shoulda/matchers/action_controller/permit_matcher.rb
Constant Summary collapse
- TOP_LEVEL =
Object.new
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params) ⇒ ParametersDoubleRegistry
constructor
A new instance of ParametersDoubleRegistry.
- #permitted_parameter_names(args = {}) ⇒ Object
- #register ⇒ Object
Constructor Details
#initialize(params) ⇒ ParametersDoubleRegistry
Returns a new instance of ParametersDoubleRegistry.
379 380 381 382 |
# File 'lib/shoulda/matchers/action_controller/permit_matcher.rb', line 379 def initialize(params) @params = params @double_collections_by_parameter_name = {} end |
Class Method Details
.permitted_parameter_names_within(double_collection) ⇒ Object
375 376 377 |
# 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 |
Instance Method Details
#permitted_parameter_names(args = {}) ⇒ Object
388 389 390 391 392 393 394 395 396 397 398 |
# 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 |
#register ⇒ Object
384 385 386 |
# File 'lib/shoulda/matchers/action_controller/permit_matcher.rb', line 384 def register register_double_for_permit_against(params, TOP_LEVEL) end |