Sha256: 5f921235487d9693d325664116ab9e1da954f1009c19fffdbff65be103c5c36d
Contents?: true
Size: 999 Bytes
Versions: 1
Compression:
Stored size: 999 Bytes
Contents
require "msgpack_rails/activesupport/message_pack" module ActiveModel module Serializers module MessagePack extend ActiveSupport::Concern include ActiveModel::Serialization included do extend ActiveModel::Naming class_attribute :include_root_in_msgpack self.include_root_in_msgpack = false end def as_msgpack(options = {}) root = if options && options.key?(:root) options[:root] else include_root_in_msgpack end if root root = self.class.model_name.element if root == true { root => serializable_hash(options) } else serializable_hash(options) end end def from_msgpack(msgpack, include_root=include_root_in_msgpack) hash = ActiveSupport::MessagePack.decode(msgpack) hash = hash.values.first if include_root self.attributes = hash self end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
msgpack_rails-0.1.0 | lib/msgpack_rails/activemodel/serializers/message_pack.rb |