Class: ActiveModelSerializers::Adapter::JsonApi::Relationship
- Inherits:
-
Object
- Object
- ActiveModelSerializers::Adapter::JsonApi::Relationship
- Defined in:
- lib/active_model_serializers/adapter/json_api/relationship.rb
Instance Method Summary collapse
- #as_json ⇒ Object
- #initialize(parent_serializer, serializable_resource_options, association) ⇒ Relationship constructor
Constructor Details
#initialize(parent_serializer, serializable_resource_options, association) ⇒ Relationship
9 10 11 12 13 |
# File 'lib/active_model_serializers/adapter/json_api/relationship.rb', line 9 def initialize(parent_serializer, , association) @parent_serializer = parent_serializer @association = association @serializable_resource_options = end |
Instance Method Details
#as_json ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/active_model_serializers/adapter/json_api/relationship.rb', line 15 def as_json hash = {} if association.[:include_data] hash[:data] = data_for(association) end links = links_for(association) hash[:links] = links if links.any? = (association) hash[:meta] = if hash[:meta] = {} if hash.empty? hash end |