Module: Centaman::JsonWrapper
- Included in:
- Service::BookingTime, Service::BookingType, Service::Capacity, Service::CouponCheck, Service::CreateCustomer, Service::Extra, Service::GiftTicket, Service::TicketType
- Defined in:
- lib/centaman/json_wrapper.rb
Overview
:nodoc:
Instance Method Summary collapse
- #additional_hash_to_serialize_after_response ⇒ Object
-
#build_object(resp) ⇒ Object
i.e.
-
#build_objects(resp) ⇒ Object
i.e.
- #object_class ⇒ Object
- #objects ⇒ Object
Instance Method Details
#additional_hash_to_serialize_after_response ⇒ Object
22 23 24 |
# File 'lib/centaman/json_wrapper.rb', line 22 def additional_hash_to_serialize_after_response {} end |
#build_object(resp) ⇒ Object
i.e. from GET of a show or POST
17 18 19 20 |
# File 'lib/centaman/json_wrapper.rb', line 17 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 |
#build_objects(resp) ⇒ Object
i.e. from GET of an index
9 10 11 12 13 14 |
# File 'lib/centaman/json_wrapper.rb', line 9 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 |
#object_class ⇒ Object
26 27 28 |
# File 'lib/centaman/json_wrapper.rb', line 26 def object_class raise "object_class is required for #{self.class.name}" end |
#objects ⇒ Object
4 5 6 |
# File 'lib/centaman/json_wrapper.rb', line 4 def objects @all ||= build_objects(self.fetch_all) end |