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
377 378 379 380 |
# File 'lib/shoulda/matchers/action_controller/permit_matcher.rb', line 377 def initialize(params) @params = params @double_collections_by_parameter_name = {} end |
Class Method Details
.permitted_parameter_names_within(double_collection) ⇒ Object
373 374 375 |
# File 'lib/shoulda/matchers/action_controller/permit_matcher.rb', line 373 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
386 387 388 389 390 391 392 393 394 395 396 |
# File 'lib/shoulda/matchers/action_controller/permit_matcher.rb', line 386 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
382 383 384 |
# File 'lib/shoulda/matchers/action_controller/permit_matcher.rb', line 382 def register register_double_for_permit_against(params, TOP_LEVEL) end |