Class: Gonebusy::BaseModel
- Inherits:
-
Object
- Object
- Gonebusy::BaseModel
- Defined in:
- lib/gonebusy/models/base_model.rb
Direct Known Subclasses
CancelBookingByIdResponse, CreateBookingBody, CreateBookingResponse, CreateCategoryBody, CreateCategoryResponse, CreatePricingModelBody, CreatePricingModelResponse, CreateResourceBody, CreateResourceResponse, CreateScheduleBody, CreateScheduleResponse, CreateScheduleTimeWindowBody, CreateScheduleTimeWindowResponse, CreateServiceBody, CreateServiceResponse, CreateUserBody, CreateUserResponse, DeleteResourceByIdResponse, DeleteScheduleByIdResponse, DeleteScheduleTimeWindowByIdResponse, DeleteServiceByIdResponse, EntitiesAddressEntity, EntitiesAvailabilityResponse, EntitiesBookingResponse, EntitiesCategoryResponse, EntitiesPricingModelResponse, EntitiesResourceAvailabilities, EntitiesResourceResponse, EntitiesScheduleResponse, EntitiesSearchResponse, EntitiesServiceResponse, EntitiesSlots, EntitiesThingTypeResponse, EntitiesTimeWindowResponse, EntitiesUserResponse, GetBookingByIdResponse, GetBookingsResponse, GetCategoriesResponse, GetCategoryByIdResponse, GetPricingModelByIdResponse, GetPricingModelsResponse, GetResourceByIdResponse, GetResourceThingsResponse, GetResourcesResponse, GetScheduleByIdResponse, GetSchedulesResponse, GetServiceAvailableSlotsByIdResponse, GetServiceByIdResponse, GetServicesResponse, GetUserByIdResponse, GetUsersResponse, SearchQueryResponse, UpdateBookingByIdBody, UpdateBookingByIdResponse, UpdatePricingModelByIdBody, UpdatePricingModelByIdResponse, UpdateResourceByIdBody, UpdateResourceByIdResponse, UpdateScheduleTimeWindowByIdBody, UpdateScheduleTimeWindowByIdResponse, UpdateServiceByIdBody, UpdateServiceByIdResponse, UpdateUserByIdBody, UpdateUserByIdResponse
Instance Method Summary collapse
-
#to_hash ⇒ Object
Returns a Hash representation of the current object.
-
#to_json(options = {}) ⇒ Object
Returns a JSON representation of the curent object.
Instance Method Details
#to_hash ⇒ Object
Returns a Hash representation of the current object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gonebusy/models/base_model.rb', line 6 def to_hash hash = {} self.instance_variables.each do |name| value = self.instance_variable_get(name) name = name[1..-1] key = self.class.names.key?(name) ? self.class.names[name] : name if value.instance_of? Array hash[key] = value.map{|v| v.kind_of?(BaseModel) ? v.to_hash : v} elsif value.instance_of? Hash hash[key] = {} value.each do |k, v| hash[key][k] = v.kind_of?(BaseModel) ? v.to_hash : v end else hash[key] = value.kind_of?(BaseModel) ? value.to_hash : value end end hash end |
#to_json(options = {}) ⇒ Object
Returns a JSON representation of the curent object
27 28 29 30 |
# File 'lib/gonebusy/models/base_model.rb', line 27 def to_json( = {}) hash = to_hash hash.to_json() end |