Module: Roar::JSON::JSONAPI::Document
- Included in:
- Collection
- Defined in:
- lib/roar/json/json_api.rb
Overview
TODO: don’t use Document for singular+wrap AND singular in collection (this way, we can get rid of the only_body)
Defined Under Namespace
Modules: Collection
Instance Method Summary collapse
Instance Method Details
#from_hash(hash, options = {}) ⇒ Object
127 128 129 130 131 132 |
# File 'lib/roar/json/json_api.rb', line 127 def from_hash(hash, ={}) return super(hash, ) if [:only_body] # singular super(from_document(hash)) # singular end |
#to_hash(options = {}) ⇒ Object
118 119 120 121 122 123 124 125 |
# File 'lib/roar/json/json_api.rb', line 118 def to_hash(={}) # per resource: res = super # render single resource or collection. return res if [:only_body] # this is the only "dirty" part: this module is always included in the Singular document representer, when used in collection, we don't want it to do the extra work. this mechanism here might be changed soon. to_document(res, ) end |