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 @@ -127,6 +127,19 @@ def self.inherited(subclass)
127
127
# should be exposed by the entity.
128
128
#
129
129
# @option options :as Declare an alias for the representation of this attribute.
130
+ # If a proc is presented it is evaluated in the context of the entity so object
131
+ # and the entity methods are available to it.
132
+ #
133
+ # @example as: a proc
134
+ #
135
+ # object = OpenStruct(awesomness: 'awesome_key', awesome: 'not-my-key' )
136
+ #
137
+ # class MyEntity < Grape::Entity
138
+ # expose :awesome, as: -> { object.awesomness }
139
+ # end
140
+ #
141
+ # => { 'awesome_key': 'not-my-key' }
142
+ #
130
143
# @option options :if When passed a Hash, the attribute will only be exposed if the
131
144
# runtime options match all the conditions passed in. When passed a lambda, the
132
145
# lambda will execute with two arguments: the object being represented and the
You can’t perform that action at this time.
0 commit comments