Sha256: b13d6ae52f9abc2ae0568e6d392d8b1560f53837a9876597c1deb6178d032a4f
Contents?: true
Size: 915 Bytes
Versions: 5
Compression:
Stored size: 915 Bytes
Contents
module ActiveResource class Base def encode(options = {}) same = dup same.attributes = {self.class.element_name => same.attributes} if self.class.format.extension == 'json' same.send("to_#{self.class.format.extension}", options) end end module Formats module JsonFormat def decode(json) data = ActiveSupport::JSON.decode(json) if data.is_a?(Hash) && data.keys.size == 1 data.values.first else data end end end end end module ActiveModel module Serializers module JSON def as_json(options = nil) root = options[:root] if options.try(:key?, :root) if include_root_in_json root = self.class.model_name.element if root == true { root => serializable_hash(options) } else serializable_hash(options) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems