Module: ParamsReady::Marshaller::EnumSetMarshallers::SetMarshaller
- Extended by:
- AbstractMarshaller
- Defined in:
- lib/params_ready/marshaller/enum_set_marshallers.rb
Class Method Summary collapse
- .canonicalize(definition, set, context, validator, freeze: false) ⇒ Object
- .marshal(parameter, intent) ⇒ Object
Methods included from AbstractMarshaller
Class Method Details
.canonicalize(definition, set, context, validator, freeze: false) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/params_ready/marshaller/enum_set_marshallers.rb', line 45 def self.canonicalize(definition, set, context, validator, freeze: false) canonicalize_collection(definition, context, validator, freeze: freeze) do |child| value = definition.values[child.name] set.member?(value) || set.member?(value.to_s) end end |
.marshal(parameter, intent) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/params_ready/marshaller/enum_set_marshallers.rb', line 52 def self.marshal(parameter, intent) intent = parameter.class.intent_for_set(intent) members = parameter.send(:bare_value).select do |_, m| m.unwrap_or(false) == true && m.eligible_for_output?(intent) end.map do |key, _| parameter.definition.values[key] end members.to_set end |