Sha256: 46149c9e419177eb5209c34a4f6d4fc99c3de4884f965f98c6ac444207c23111

Contents?: true

Size: 432 Bytes

Versions: 17

Compression:

Stored size: 432 Bytes

Contents

# We do not recommend that you use AM::S in this way, but if you must, here
# is a mixin that overrides ActiveRecord::Base#to_json and #as_json.

module ActiveRecord
  module SerializerOverride
    def to_json options = {}
      active_model_serializer.new(self).to_json options
    end

    def as_json options={}
      active_model_serializer.new(self).as_json options
    end
  end

  Base.send(:include, SerializerOverride)
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
active_model_serializers-0.8.4 lib/active_record/serializer_override.rb
active_model_serializers-0.8.3 lib/active_record/serializer_override.rb
active_model_serializers-0.8.2 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.5 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.5.alpha1 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.4 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.4.alpha5 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.4.alpha4 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.4.alpha3 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.4.alpha2 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.4.alpha1 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.3.rc1 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.3.alpha2 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.3.alpha1 lib/active_record/serializer_override.rb
gpi-active_model_serializers-0.8.2 lib/active_record/serializer_override.rb
active_model_serializers-0.8.1 lib/active_record/serializer_override.rb
active_model_serializers-0.8.0 lib/active_record/serializer_override.rb