File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,19 @@ def self.inherited(subclass)
125125 # should be exposed by the entity.
126126 #
127127 # @option options :as Declare an alias for the representation of this attribute.
128+ # If a proc is presented it is evaluated in the context of the entity so object
129+ # and the entity methods are available to it.
130+ #
131+ # @example as: a proc
132+ #
133+ # object = OpenStruct(awesomness: 'awesome_key', awesome: 'not-my-key' )
134+ #
135+ # class MyEntity < Grape::Entity
136+ # expose :awesome, as: -> { object.awesomness }
137+ # end
138+ #
139+ # => { 'awesome_key': 'not-my-key' }
140+ #
128141 # @option options :if When passed a Hash, the attribute will only be exposed if the
129142 # runtime options match all the conditions passed in. When passed a lambda, the
130143 # lambda will execute with two arguments: the object being represented and the
You can’t perform that action at this time.
0 commit comments