Class: Datacenter

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
RocketPants::Cacheable
Defined in:
app/models/datacenter.rb

Overview

Datacenter model

id: integer
name: string
description: text
created_at: datetime
updated_at: datetime
rack_prefix: string
max_floors: integer
max_rows_per_floor: integer
max_cells_per_row: integer
has_many :rack_locations (class_name :DatacenterRackLocation)
has_many :racks (through :rack_locations)

A datacenter has many racks, each at a certain unique position (floor, row, cell). The attributes :rack_prefix, :max_floors, :max_rows_per_floor and :max_cells_per_row are used for generating rack labels in the DatacenterRack model.

Constant Summary collapse

DEFAULTS =
{
  max_floors: 16,
  max_rows_per_floor: 16,
  max_cells_per_row: 16
}

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Datacenter

Returns a new instance of Datacenter


30
31
32
33
# File 'app/models/datacenter.rb', line 30

def initialize(attributes = {})
  attr_with_defaults = DEFAULTS.merge(attributes)
  super(attr_with_defaults)
end