Class: ApiSerializer::AttributeOptions
- Inherits:
-
Object
- Object
- ApiSerializer::AttributeOptions
- Defined in:
- lib/api_serializer/attribute_options.rb
Instance Attribute Summary collapse
-
#allowed_values ⇒ Object
readonly
Returns the value of attribute allowed_values.
-
#composed_of ⇒ Object
readonly
Returns the value of attribute composed_of.
-
#convert_by ⇒ Object
readonly
Returns the value of attribute convert_by.
-
#decompose_to ⇒ Object
readonly
Returns the value of attribute decompose_to.
-
#from_path ⇒ Object
readonly
Returns the value of attribute from_path.
-
#nested_schema ⇒ Object
readonly
Returns the value of attribute nested_schema.
-
#query_column ⇒ Object
readonly
Returns the value of attribute query_column.
-
#query_transform ⇒ Object
readonly
Returns the value of attribute query_transform.
-
#virtual ⇒ Object
readonly
Returns the value of attribute virtual.
Instance Method Summary collapse
- #association? ⇒ Boolean
- #coercion ⇒ Object
- #compose? ⇒ Boolean
- #decompose? ⇒ Boolean
- #default ⇒ Object
- #filterable? ⇒ Boolean
-
#initialize(attribute_reflection, from_path:, composed_of:, decompose_to:, convert_by:, virtual:, queryable: nil, nested_schema: nil) ⇒ AttributeOptions
constructor
A new instance of AttributeOptions.
- #name ⇒ Object
- #positional ⇒ Object
- #reader ⇒ Object
- #sortable? ⇒ Boolean
- #to_h ⇒ Object
- #type ⇒ Object
- #virtual? ⇒ Boolean
Constructor Details
#initialize(attribute_reflection, from_path:, composed_of:, decompose_to:, convert_by:, virtual:, queryable: nil, nested_schema: nil) ⇒ AttributeOptions
Returns a new instance of AttributeOptions.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/api_serializer/attribute_options.rb', line 3 def initialize(attribute_reflection, from_path:, composed_of:, decompose_to:, convert_by:, virtual:, queryable: nil, nested_schema: nil) @attribute_reflection = attribute_reflection @from_path = from_path @composed_of = composed_of @decompose_to = decompose_to @convert_by = convert_by @virtual = virtual @nested_schema = nested_schema config = queryable ? normalize_queryable(queryable) : QueryableConfig.new(filter: false, sort: false) @filterable = config.filterable? @sortable = config.sortable? @query_column = config.column @query_transform = config.transform @allowed_values = config.allowed_values end |
Instance Attribute Details
#allowed_values ⇒ Object (readonly)
Returns the value of attribute allowed_values.
27 28 29 |
# File 'lib/api_serializer/attribute_options.rb', line 27 def allowed_values @allowed_values end |
#composed_of ⇒ Object (readonly)
Returns the value of attribute composed_of.
27 28 29 |
# File 'lib/api_serializer/attribute_options.rb', line 27 def composed_of @composed_of end |
#convert_by ⇒ Object (readonly)
Returns the value of attribute convert_by.
27 28 29 |
# File 'lib/api_serializer/attribute_options.rb', line 27 def convert_by @convert_by end |
#decompose_to ⇒ Object (readonly)
Returns the value of attribute decompose_to.
27 28 29 |
# File 'lib/api_serializer/attribute_options.rb', line 27 def decompose_to @decompose_to end |
#from_path ⇒ Object (readonly)
Returns the value of attribute from_path.
27 28 29 |
# File 'lib/api_serializer/attribute_options.rb', line 27 def from_path @from_path end |
#nested_schema ⇒ Object (readonly)
Returns the value of attribute nested_schema.
27 28 29 |
# File 'lib/api_serializer/attribute_options.rb', line 27 def nested_schema @nested_schema end |
#query_column ⇒ Object (readonly)
Returns the value of attribute query_column.
27 28 29 |
# File 'lib/api_serializer/attribute_options.rb', line 27 def query_column @query_column end |
#query_transform ⇒ Object (readonly)
Returns the value of attribute query_transform.
27 28 29 |
# File 'lib/api_serializer/attribute_options.rb', line 27 def query_transform @query_transform end |
#virtual ⇒ Object (readonly)
Returns the value of attribute virtual.
27 28 29 |
# File 'lib/api_serializer/attribute_options.rb', line 27 def virtual @virtual end |
Instance Method Details
#association? ⇒ Boolean
35 |
# File 'lib/api_serializer/attribute_options.rb', line 35 def association? = !!@nested_schema |
#coercion ⇒ Object
25 |
# File 'lib/api_serializer/attribute_options.rb', line 25 def coercion = @attribute_reflection.coercion |
#compose? ⇒ Boolean
30 |
# File 'lib/api_serializer/attribute_options.rb', line 30 def compose? = !!composed_of |
#decompose? ⇒ Boolean
31 |
# File 'lib/api_serializer/attribute_options.rb', line 31 def decompose? = !!decompose_to |
#default ⇒ Object
24 |
# File 'lib/api_serializer/attribute_options.rb', line 24 def default = @attribute_reflection.default |
#filterable? ⇒ Boolean
33 |
# File 'lib/api_serializer/attribute_options.rb', line 33 def filterable? = !!@filterable |
#name ⇒ Object
20 |
# File 'lib/api_serializer/attribute_options.rb', line 20 def name = @attribute_reflection.name |
#positional ⇒ Object
23 |
# File 'lib/api_serializer/attribute_options.rb', line 23 def positional = @attribute_reflection.positional |
#reader ⇒ Object
22 |
# File 'lib/api_serializer/attribute_options.rb', line 22 def reader = @attribute_reflection.reader |
#sortable? ⇒ Boolean
34 |
# File 'lib/api_serializer/attribute_options.rb', line 34 def sortable? = !!@sortable |
#to_h ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/api_serializer/attribute_options.rb', line 37 def to_h { name:, type:, reader:, positional:, default:, composed_of:, decompose_to:, convert_by:, from_path:, virtual:, filterable: @filterable, sortable: @sortable, query_column: @query_column, query_transform: @query_transform, allowed_values: @allowed_values, nested_schema: @nested_schema } end |
#type ⇒ Object
21 |
# File 'lib/api_serializer/attribute_options.rb', line 21 def type = @attribute_reflection.type |
#virtual? ⇒ Boolean
32 |
# File 'lib/api_serializer/attribute_options.rb', line 32 def virtual? = !!virtual |