We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d5756b2 commit 33513fcCopy full SHA for 33513fc
lib/active_model/serializer.rb
@@ -116,6 +116,16 @@ def self.attributes(*attrs)
116
# def recent_edits
117
# object.edits.last(5)
118
# end
119
+ # TODO: re-add block support
120
+ # if block_given?
121
+ # serialized_attributes[key] = ->(instance) { instance.instance_eval(&block) }
122
+ # else
123
+ # serialized_attributes[key] = ->(instance) { instance.object.read_attribute_for_serialization(attr) }
124
+ # end
125
+ #
126
+ # ActiveModelSerializers.silence_warnings do
127
+ # define_method key do
128
+ # serialized_attributes[key].call(self)
129
def self.attribute(attr, options = {}, &block)
130
key = options.fetch(:key, attr)
131
_attributes_map[key] = attr
0 commit comments