Sha256: c96bc0787322e8042295389a57c8e906c7d8aa922228bf363783a44c963b5bfc

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require 'active_model'
require 'active_model/serializer'
require 'active_model/serializer_support'
require 'active_model/serializer/version'
require 'active_model/serializer/railtie' if defined?(Rails)

begin
  require 'action_controller'
  require 'action_controller/serialization'

  ActiveSupport.on_load(:action_controller) do
    if ::ActionController::Serialization.enabled
      ActionController::Base.send(:include, ::ActionController::Serialization)

      # action_controller_test_case load hook was added in Rails 5.1
      # https://github.com/rails/rails/commit/0510208dd1ff23baa619884c0abcae4d141fae53
      if ActiveSupport::VERSION::STRING < '5.1'
        require 'action_controller/serialization_test_case'
        ActionController::TestCase.send(:include, ::ActionController::SerializationAssertions)
      else
        ActiveSupport.on_load(:action_controller_test_case) do
          require 'action_controller/serialization_test_case'
          ActionController::TestCase.send(:include, ::ActionController::SerializationAssertions)
        end
      end
    end
  end
rescue LoadError
  # rails not installed, continuing
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_model_serializers-0.9.13 lib/active_model_serializers.rb
active_model_serializers-0.9.12 lib/active_model_serializers.rb
active_model_serializers-0.9.11 lib/active_model_serializers.rb