Class: SimpleMetrics::Dashboard

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_metrics/dashboard.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Dashboard

Returns a new instance of Dashboard.



7
8
9
10
11
12
13
# File 'lib/simple_metrics/dashboard.rb', line 7

def initialize(attributes)
  @id          = attributes[:id]
  @name        = attributes[:name]
  @created_at  = attributes[:created_at]
  @updated_at  = attributes[:updated_at]
  @instruments = attributes[:instruments] || []
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



4
5
6
# File 'lib/simple_metrics/dashboard.rb', line 4

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/simple_metrics/dashboard.rb', line 4

def id
  @id
end

#instrumentsObject

Returns the value of attribute instruments.



5
6
7
# File 'lib/simple_metrics/dashboard.rb', line 5

def instruments
  @instruments
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/simple_metrics/dashboard.rb', line 5

def name
  @name
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



4
5
6
# File 'lib/simple_metrics/dashboard.rb', line 4

def updated_at
  @updated_at
end

Instance Method Details

#attributesObject



15
16
17
18
19
20
21
22
23
# File 'lib/simple_metrics/dashboard.rb', line 15

def attributes
  { 
    :id          => @id.to_s, # convert bson id to str
    :name        => @name,
    :instruments => @instruments,
    :created_at  => @created_at,
    :updated_at  => @updated_at
  }
end

#to_sObject



25
26
27
# File 'lib/simple_metrics/dashboard.rb', line 25

def to_s
  attributes.to_s
end