Sha256: 23a4b651eb8364b7092f10cc537c0f9e0886b7986398ae20361fc16158fac366
Contents?: true
Size: 768 Bytes
Versions: 20
Compression:
Stored size: 768 Bytes
Contents
module Centaman #:nodoc: module JsonWrapper def objects @all ||= build_objects(self.fetch_all) end # i.e. from GET of an index def build_objects(resp) return [] unless resp.respond_to?(:map) @tickets = resp.map do |ticket_hash| object_class.new(ticket_hash.merge(additional_hash_to_serialize_after_response)) end end # i.e. from GET of a show or POST def build_object(resp) return resp unless resp.respond_to?(:merge) @build_object ||= object_class.new(resp.merge(additional_hash_to_serialize_after_response)) end def additional_hash_to_serialize_after_response {} end def object_class raise "object_class is required for #{self.class.name}" end end end
Version data entries
20 entries across 20 versions & 1 rubygems