Class: ApiSerializer::TargetDataStructure

Inherits:
TypedStruct
  • Object
show all
Defined in:
lib/api_serializer/target_data_structure.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TypedStruct

attribute_names, attribute_options, #attributes, #inspect, #merge, reflect_on

Class Method Details

.attribute(name, type, from_path: nil, composed_of: nil, decompose_to: nil, convert_by: nil, virtual: false, queryable: nil, nested_schema: nil) ⇒ Object



4
5
6
7
8
# File 'lib/api_serializer/target_data_structure.rb', line 4

def attribute(name, type, from_path: nil, composed_of: nil, decompose_to: nil, convert_by: nil, virtual: false, queryable: nil, nested_schema: nil, **, &)
  super(name, type, **, &)

  @attribute_options[name] = AttributeOptions.new(@attribute_options[name], from_path:, composed_of:, decompose_to:, convert_by:, virtual:, queryable:, nested_schema:)
end

Instance Method Details

#as_json(_options = nil) ⇒ Object



11
12
13
# File 'lib/api_serializer/target_data_structure.rb', line 11

def as_json(_options = nil)
  to_h.transform_values { |v| json_value(v) }
end