Method: Grape::DSL::RequestResponse::ClassMethods#represent
- Defined in:
- lib/grape/dsl/request_response.rb
#represent(model_class, options) ⇒ Object
Allows you to specify a default representation entity for a class. This allows you to map your models to their respective entities once and then simply call ‘present` with the model.
Note that Grape will automatically go up the class ancestry to try to find a representing entity, so if you, for example, define an entity to represent ‘Object` then all presented objects will bubble up and utilize the entity provided on that `represent` call.
154 155 156 157 |
# File 'lib/grape/dsl/request_response.rb', line 154 def represent(model_class, ) raise Grape::Exceptions::InvalidWithOptionForRepresent.new unless [:with] && [:with].is_a?(Class) namespace_stackable(:representations, model_class => [:with]) end |