Class: MediaTypes::Serialization::SerializationAliasRegistration
- Inherits:
-
SerializationBaseRegistration
- Object
- SerializationBaseRegistration
- MediaTypes::Serialization::SerializationAliasRegistration
- Defined in:
- lib/media_types/serialization/serialization_registration.rb
Overview
A registration that calls another registration when called.
Instance Attribute Summary collapse
-
#hide_variant ⇒ Object
Returns the value of attribute hide_variant.
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#target ⇒ Object
Returns the value of attribute target.
Attributes inherited from SerializationBaseRegistration
#display_identifier, #inout, #serializer, #validator
Instance Method Summary collapse
- #call(victim, context, dsl: nil, raw: nil) ⇒ Object
- #decode(victim, context) ⇒ Object
-
#initialize(serializer, inout, validator, display_identifier, target, optional, hide_variant) ⇒ SerializationAliasRegistration
constructor
A new instance of SerializationAliasRegistration.
- #merge(other) ⇒ Object
Constructor Details
#initialize(serializer, inout, validator, display_identifier, target, optional, hide_variant) ⇒ SerializationAliasRegistration
Returns a new instance of SerializationAliasRegistration.
216 217 218 219 220 221 |
# File 'lib/media_types/serialization/serialization_registration.rb', line 216 def initialize(serializer, inout, validator, display_identifier, target, optional, hide_variant) self.target = target self.optional = optional self.hide_variant = hide_variant super(serializer, inout, validator, display_identifier) end |
Instance Attribute Details
#hide_variant ⇒ Object
Returns the value of attribute hide_variant.
242 243 244 |
# File 'lib/media_types/serialization/serialization_registration.rb', line 242 def hide_variant @hide_variant end |
#optional ⇒ Object
Returns the value of attribute optional.
242 243 244 |
# File 'lib/media_types/serialization/serialization_registration.rb', line 242 def optional @optional end |
#target ⇒ Object
Returns the value of attribute target.
242 243 244 |
# File 'lib/media_types/serialization/serialization_registration.rb', line 242 def target @target end |
Instance Method Details
#call(victim, context, dsl: nil, raw: nil) ⇒ Object
238 239 240 |
# File 'lib/media_types/serialization/serialization_registration.rb', line 238 def call(victim, context, dsl: nil, raw: nil) target.call(victim, context, dsl: dsl, raw: raw) end |
#decode(victim, context) ⇒ Object
234 235 236 |
# File 'lib/media_types/serialization/serialization_registration.rb', line 234 def decode(victim, context) target.decode(victim, context) end |
#merge(other) ⇒ Object
223 224 225 226 227 228 229 230 231 232 |
# File 'lib/media_types/serialization/serialization_registration.rb', line 223 def merge(other) if optional return other unless other.is_a?(SerializationAliasRegistration) else return nil if other.is_a?(SerializationAliasRegistration) && !other.optional # two non-optional can't merge return self end other # if both optional, or other is !optional, newer one wins. end |