Sha256: 242983c2dc25a9639692db7d3fb801b0f627abed2a8bdab3486bce0810f4660e
Contents?: true
Size: 612 Bytes
Versions: 3
Compression:
Stored size: 612 Bytes
Contents
require 'active_model/serializable' module ActiveModel # DefaultSerializer # # Provides a constant interface for all items class DefaultSerializer include ActiveModel::Serializable attr_reader :object def initialize(object, options={}) @object = object @wrap_in_array = options[:_wrap_in_array] end def as_json(options={}) instrument do return [] if @object.nil? && @wrap_in_array hash = @object.as_json @wrap_in_array ? [hash] : hash end end alias serializable_hash as_json alias serializable_object as_json end end
Version data entries
3 entries across 3 versions & 1 rubygems