Class: ParamsReady::Parameter::StructParameterDefinition
- Inherits:
-
AbstractStructParameterDefinition
- Object
- AbstractDefinition
- Definition
- AbstractStructParameterDefinition
- ParamsReady::Parameter::StructParameterDefinition
- Defined in:
- lib/params_ready/parameter/struct_parameter.rb
Direct Known Subclasses
ParamsReady::Pagination::KeysetPaginationDefinition, StateDefinition, Query::ArrayGroupingDefinition, Query::StructuredGroupingDefinition
Instance Attribute Summary
Attributes inherited from AbstractStructParameterDefinition
Attributes inherited from Definition
Attributes inherited from AbstractDefinition
Instance Method Summary collapse
Methods inherited from AbstractStructParameterDefinition
#add_child, #child_definition, #duplicate_value, #freeze_value, #has_child?, #infer_default, #initialize, #set_default
Methods inherited from Definition
#canonical_default, #default_defined?, #fetch_callable_default, #fetch_default, #finish, #initialize, #memoize?, #name_for_formatter, #no_input?, #no_output?, #postprocess, #preprocess, #restricted_for_format?, #set_local, #set_no_input, #set_postprocessor, #set_preprocessor
Methods inherited from AbstractDefinition
#create, #finish, #from_hash, #from_input, #initialize, #normalize_alternative_name, #parameter_class
Methods included from Extensions::Freezer
#freeze_variable, #freeze_variables, #variables_to_freeze
Methods included from Extensions::Finalizer
Methods included from Extensions::ClassReaderWriter
Methods included from Extensions::LateInit
Methods included from Extensions::Collection
Methods included from Extensions::Finalizer::InstanceMethods
Methods included from Extensions::Freezer::InstanceMethods
Constructor Details
This class inherits a constructor from ParamsReady::Parameter::AbstractStructParameterDefinition
Instance Method Details
#add_map(hash) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/params_ready/parameter/struct_parameter.rb', line 51 def add_map(hash) @key_map ||= Helpers::KeyMap.new hash.each do |key, value| @key_map.map(key, to: value) end end |
#ensure_canonical(hash) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/params_ready/parameter/struct_parameter.rb', line 35 def ensure_canonical(hash) context = Format.instance(:backend) value, _validator = try_canonicalize hash, context, nil, freeze: true return value if value.length == hash.length extra_keys = hash.keys.select do |key| !value.key?(key) end.map do |key| "'#{key.to_s}'" end.join(", ") raise ParamsReadyError, "extra keys found -- #{extra_keys}" if extra_keys.length > 0 value end |
#remap?(context) ⇒ Boolean
58 59 60 61 |
# File 'lib/params_ready/parameter/struct_parameter.rb', line 58 def remap?(context) return false if key_map.nil? context.remap? end |