class ActiveModel::AsJsonFilter::AsJsonOptions

封装 as_json 参数

Constants

OptionFields

Attributes

finalizer_proc[RW]

不要使用方法污染了方法空间。

比如: 可以在这里返回 键id 为别的非主键的值,以应对客户端刁难的需求。 self.as_json_options.finalizer_proc = lambda do |result, item|

result['id']        = item.uuid.hash % 2**31
return result

end

Public Class Methods

new() click to toggle source
# File lib/active_model_as_json_filter.rb, line 40
def initialize
  @only, @except, @methods = SetWithMultiplePush.new, SetWithMultiplePush.new, SetWithMultiplePush.new
  @finalizer_proc = lambda {|hash, item = nil| return hash.merge(Hash.new) }
end