Sha256: 2bf6188ab98e120869b204345b42155edf09b8ab661e41e16af7879d8e3369ad
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require "active_support" require "msgpack_rails/version" module ActiveSupport eager_autoload do autoload :MessagePack, "msgpack_rails/activesupport/message_pack" end end if defined?(ActiveModel) module ActiveModel module Serializers eager_autoload do autoload :MessagePack, "msgpack_rails/activemodel/serializers/message_pack" end end end end if defined?(::Rails) module MsgpackRails class Rails < ::Rails::Engine initializer "msgpack_rails" do if defined?(::ActiveRecord::Base) ::ActiveSupport.on_load(:active_record) do ::ActiveRecord::Base.send(:include, ActiveModel::Serializers::MessagePack) end end if defined?(::Mongoid::Document) ::ActiveSupport.on_load(:mongoid) do ::Mongoid::Document.send(:include, ActiveModel::Serializers::MessagePack) end end ::Mime::Type.register "application/msgpack", :msgpack if ::Rails::VERSION::MAJOR > 3 || ::Rails::VERSION::MINOR > 0 ::ActionController::Renderers.add :msgpack do |data, options| self.content_type = Mime[:msgpack] data.is_a?(String) ? data : data.to_msgpack(options) end else ::ActionController::Renderers.add :msgpack do |data, options| self.content_type = Mime[:msgpack] self.response_body = data.is_a?(String) ? data : data.to_msgpack(options) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
msgpack_rails-0.4.3 | lib/msgpack_rails.rb |