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
11 12 13 14 15 |
# File 'lib/active_model_serializers/adapter/json_api/relationship.rb', line 11 def initialize(parent_serializer, , association) @parent_serializer = parent_serializer @association = association @serializable_resource_options = end |
Instance Method Details
#as_json ⇒ Object
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 17 def as_json hash = {} hash[:data] = data_for(association) if association.include_data? links = links_for(association) hash[:links] = links if links.any? = (association) hash[:meta] = if hash[:meta] = {} if hash.empty? hash end |