Skip to content

Commit

Permalink
Add documentation to the as: option.
Browse files Browse the repository at this point in the history
  • Loading branch information
James McCarthy committed Apr 5, 2017
1 parent af35d4a commit 1cce99f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/grape_entity/entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ def self.inherited(subclass)
# should be exposed by the entity.
#
# @option options :as Declare an alias for the representation of this attribute.
# If a proc is presented it is evaluated in the context of the entity so object
# and the entity methods are available to it.
#
# @example as: a proc
#
# object = OpenStruct(awesomness: 'awesome_key', awesome: 'not-my-key' )
#
# class MyEntity < Grape::Entity
# expose :awesome, as: -> { object.awesomness }
# end
#
# => { 'awesome_key': 'not-my-key' }
#
# @option options :if When passed a Hash, the attribute will only be exposed if the
# runtime options match all the conditions passed in. When passed a lambda, the
# lambda will execute with two arguments: the object being represented and the
Expand Down

0 comments on commit 1cce99f

Please sign in to comment.