Class: ApiSerializer::Variants::Variant
- Inherits:
-
Object
- Object
- ApiSerializer::Variants::Variant
show all
- Defined in:
- lib/api_serializer/variants/variant.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name:, serialization:, inherits: nil) ⇒ Variant
Returns a new instance of Variant.
4
5
6
7
8
9
|
# File 'lib/api_serializer/variants/variant.rb', line 4
def initialize(name:, serialization:, inherits: nil)
@name = name
@serialization = serialization
@transformer = serialization.transformer
@inherits = inherits
end
|
Instance Attribute Details
#inherits ⇒ Object
Returns the value of attribute inherits.
11
12
13
|
# File 'lib/api_serializer/variants/variant.rb', line 11
def inherits
@inherits
end
|
#name ⇒ Object
Returns the value of attribute name.
11
12
13
|
# File 'lib/api_serializer/variants/variant.rb', line 11
def name
@name
end
|
#serialization ⇒ Object
Returns the value of attribute serialization.
11
12
13
|
# File 'lib/api_serializer/variants/variant.rb', line 11
def serialization
@serialization
end
|
Returns the value of attribute transformer.
11
12
13
|
# File 'lib/api_serializer/variants/variant.rb', line 11
def transformer
@transformer
end
|
Instance Method Details
#==(other) ⇒ Object
35
36
37
|
# File 'lib/api_serializer/variants/variant.rb', line 35
def ==(other)
eql?(other)
end
|
#abstract? ⇒ Boolean
27
28
29
|
# File 'lib/api_serializer/variants/variant.rb', line 27
def abstract?
false
end
|
#attribute_names ⇒ Object
17
|
# File 'lib/api_serializer/variants/variant.rb', line 17
def attribute_names = serialization.attribute_names
|
#composed_with ⇒ Object
18
|
# File 'lib/api_serializer/variants/variant.rb', line 18
def composed_with = serialization.composed_with
|
#eql?(other) ⇒ Boolean
31
32
33
|
# File 'lib/api_serializer/variants/variant.rb', line 31
def eql?(other)
other.class == self.class && other.name == name && serialization == other.serialization
end
|
#filtering_mapped_attributes(**opts) ⇒ Object
20
|
# File 'lib/api_serializer/variants/variant.rb', line 20
def filtering_mapped_attributes(**opts) = serialization.filtering_mapped_attributes(**opts)
|
#reflect_on(name) ⇒ Object
19
|
# File 'lib/api_serializer/variants/variant.rb', line 19
def reflect_on(name) = serialization.reflect_on(name)
|
#resolved_name ⇒ Object
23
24
25
|
# File 'lib/api_serializer/variants/variant.rb', line 23
def resolved_name
abstract? ? :"abstract_#{name}" : name
end
|
#sorting_mapped_attributes(**opts) ⇒ Object
21
|
# File 'lib/api_serializer/variants/variant.rb', line 21
def sorting_mapped_attributes(**opts) = serialization.sorting_mapped_attributes(**opts)
|
13
14
15
|
# File 'lib/api_serializer/variants/variant.rb', line 13
def transform(data, context = {})
transformer.transform(data, context)
end
|