class Backend::House
House
in memory
Attributes
bathrooms[RW]
Attributes of a house
garages[RW]
Attributes of a house
id[RW]
Attributes of a house
name[RW]
Attributes of a house
rooms[RW]
Attributes of a house
Public Class Methods
new(house_params)
click to toggle source
Create a new house
# File lib/house_test/backend/house.rb, line 9 def initialize(house_params) params = IndifferentHash.new(house_params) self.name = params[:name] || Faker::Name.name self.rooms = (params[:rooms] || Faker::Number.number(digits: 1)).to_i self.garages = params[:garages] || 1 self.bathrooms = params[:bathrooms] || rooms - 1 self.id = SecureRandom.uuid end
Public Instance Methods
description()
click to toggle source
@string [String] JSON representation of House
# File lib/house_test/backend/house.rb, line 20 def description JSON.generate(id: id, name: name, rooms: rooms, bathrooms: bathrooms, garages: garages) end