File tree 1 file changed +13
-0
lines changed
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)
125
125
# should be exposed by the entity.
126
126
#
127
127
# @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
+ #
128
141
# @option options :if When passed a Hash, the attribute will only be exposed if the
129
142
# runtime options match all the conditions passed in. When passed a lambda, the
130
143
# lambda will execute with two arguments: the object being represented and the
You can’t perform that action at this time.
0 commit comments