Sha256: 639a67e47ffc1241a2f429154737ff46742959116acfa56134894fff89f00100

Contents?: true

Size: 545 Bytes

Versions: 3

Compression:

Stored size: 545 Bytes

Contents

# frozen_string_literal: true

require 'adequate_serialization/rails/cache_key'
require 'adequate_serialization/rails/cache_step'
require 'adequate_serialization/rails/relation_serializer'

module AdequateSerialization
  module Rails
    module RelationHook
      def as_json(*options)
        RelationSerializer.new(self).as_json(*options)
      end
    end

    def self.hook_in!
      ActiveRecord::Base.include(Serializable)
      ActiveRecord::Relation.include(RelationHook)
      AdequateSerialization.prepend(CacheStep)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adequate_serialization-0.1.1 lib/adequate_serialization/rails/hook.rb
adequate_serialization-0.1.0 lib/adequate_serialization/rails/hook.rb
adequate_serialization-0.0.1 lib/adequate_serialization/rails/hook.rb