Class: ActiveModelSerializers::Adapter::JsonApiPg
- Inherits:
-
Base
- Object
- Base
- ActiveModelSerializers::Adapter::JsonApiPg
- Defined in:
- lib/active_model_serializers/adapter/json_api_pg.rb
Instance Method Summary collapse
-
#initialize(serializer, options = {}) ⇒ JsonApiPg
constructor
A new instance of JsonApiPg.
- #relation ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(serializer, options = {}) ⇒ JsonApiPg
21 22 23 |
# File 'lib/active_model_serializers/adapter/json_api_pg.rb', line 21 def initialize(serializer, ={}) super end |
Instance Method Details
#relation ⇒ Object
38 39 40 |
# File 'lib/active_model_serializers/adapter/json_api_pg.rb', line 38 def relation @relation ||= _relation end |
#to_json(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/active_model_serializers/adapter/json_api_pg.rb', line 25 def to_json(={}) if relation.nil? ret = { data: [] } if includes.any? # TODO: Can included ever be non-empty when the main data is empty? ret[:included] = [] end ret.to_json else connection.select_value serializer_sql end end |