Module: ActsAsApi::Collection
- Defined in:
- lib/acts_as_api/collection.rb
Instance Method Summary collapse
-
#as_api_response(api_template, options = {}) ⇒ Object
The collection checks all its items if they respond to the
as_api_responsemethod.
Instance Method Details
#as_api_response(api_template, options = {}) ⇒ Object
The collection checks all its items if they respond to the as_api_response method. If they do, the result of this method will be collected. If they don’t, the item itself will be collected.
6 7 8 9 10 11 12 13 14 |
# File 'lib/acts_as_api/collection.rb', line 6 def as_api_response(api_template, = {}) collect do |item| if item.respond_to?(:as_api_response) item.as_api_response(api_template, ) else item end end end |