Module: Brainstem::Concerns::ControllerDSL
- Extended by:
- ActiveSupport::Concern
- Includes:
- InheritableConfiguration
- Included in:
- Brainstem::ControllerMethods
- Defined in:
- lib/brainstem/concerns/controller_dsl.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- DEFAULT_BRAINSTEM_PARAMS_CONTEXT =
:_default
Instance Method Summary collapse
-
#brainstem_valid_params(requested_context = action_name.to_sym, root_param_name = brainstem_model_name) ⇒ Hash{String => String, Hash] a hash of pairs of param names and
(also: #brainstem_valid_params_for)
Lists all valid parameters for the current action.
-
#transforms(requested_context = action_name.to_sym) ⇒ Hash{Symbol => Symbol}
(also: #transforms_for)
Lists all incoming param keys that will be rewritten to use a different name for internal usage for the current action.
Methods included from InheritableConfiguration
Instance Method Details
#brainstem_valid_params(requested_context = action_name.to_sym, root_param_name = brainstem_model_name) ⇒ Hash{String => String, Hash] a hash of pairs of param names and Also known as: brainstem_valid_params_for
Lists all valid parameters for the current action. Falls back to the valid parameters for the default context.
descriptions or sub-hashes.
248 249 250 251 252 253 254 255 |
# File 'lib/brainstem/concerns/controller_dsl.rb', line 248 def brainstem_valid_params(requested_context = action_name.to_sym, root_param_name = brainstem_model_name) contextual_key(requested_context, :valid_params) .to_h .select do |k, v| root = v[:root].respond_to?(:call) ? v[:root].call(self.class) : v[:root] root.to_s == root_param_name.to_s end end |
#transforms(requested_context = action_name.to_sym) ⇒ Hash{Symbol => Symbol} Also known as: transforms_for
Lists all incoming param keys that will be rewritten to use a different name for internal usage for the current action.
Rewrites all params to be symbols for backwards compatibility.
270 271 272 273 274 275 276 |
# File 'lib/brainstem/concerns/controller_dsl.rb', line 270 def transforms(requested_context = action_name.to_sym) tforms = contextual_key(requested_context, :transforms).to_h tforms.inject({}) do |memo, (k, v)| memo[k.to_sym] = v.to_sym memo end end |