module Centaman::JsonWrapper
Public Instance Methods
additional_hash_to_serialize_after_response()
click to toggle source
# File lib/centaman/json_wrapper.rb, line 22 def additional_hash_to_serialize_after_response {} end
build_object(resp)
click to toggle source
i.e. from GET of a show or POST
# File lib/centaman/json_wrapper.rb, line 17 def build_object(resp) return resp unless resp.respond_to?(:merge) @build_object ||= final_object_class.new(resp.merge(additional_hash_to_serialize_after_response)) end
build_objects(resp)
click to toggle source
i.e. from GET of an index
# File lib/centaman/json_wrapper.rb, line 9 def build_objects(resp) return [] unless resp.respond_to?(:map) @tickets = resp.map do |ticket_hash| final_object_class.new(ticket_hash.merge(additional_hash_to_serialize_after_response)) end end
final_object_class()
click to toggle source
# File lib/centaman/json_wrapper.rb, line 30 def final_object_class name = object_class.name.split('::').last override = Centaman.configuration.object_overrides[name] override_class = override.constantize if override override_class || object_class end
object_class()
click to toggle source
# File lib/centaman/json_wrapper.rb, line 26 def object_class raise "object_class is required for #{self.class.name}" end
objects()
click to toggle source
# File lib/centaman/json_wrapper.rb, line 4 def objects @all ||= build_objects(self.fetch_all) end