Class: Mouth::Dashboard

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

Overview

A dashboard has these fields:

id
name
todo: order

Instance Attribute Summary

Attributes inherited from Record

#attributes

Instance Method Summary collapse

Methods inherited from Record

all, collection, create, find, #initialize, #normalize_attributes, #save, #update

Constructor Details

This class inherits a constructor from Mouth::Record

Instance Method Details

#all_attributesObject



9
10
11
# File 'lib/mouth/dashboard.rb', line 9

def all_attributes
  self.attributes.tap {|attrs| attrs[:graphs] = graphs.collect(&:all_attributes) }
end

#destroyObject



13
14
15
16
# File 'lib/mouth/dashboard.rb', line 13

def destroy
  self.graphs.each(&:destroy)
  super
end

#graphsObject

An array of graphs



19
20
21
22
23
# File 'lib/mouth/dashboard.rb', line 19

def graphs
  @graphs ||= begin
    Graph.for_dashboard(self.attributes[:id])
  end
end