Module: ActiveModel::Serializer::OjOptionsCompat

Defined in:
lib/oj_serializers/compat.rb

Instance Method Summary collapse

Instance Method Details

#add_attribute(value_from, key: nil, **options) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/oj_serializers/compat.rb', line 51

def add_attribute(value_from, key: nil, **options)
  options[:as] ||= key if key

  if (unless_proc = options.delete(:unless))
    options[:if] = -> { !instance_exec(&unless_proc) }
  end

  super(value_from, **options)
end