Class: Carload::Dashboard

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

Direct Known Subclasses

Dashboard

Defined Under Namespace

Classes: ModelSpec

Class Method Summary collapse

Class Method Details

.associate(args) ⇒ Object



28
29
30
31
32
33
# File 'lib/carload/dashboard.rb', line 28

def associate args
  model_a = args.keys.first
  model_b = args.values.first
  @@models[model_a].associated_models[model_b] = args[:choose_by]
  @@models[model_b].associated_models[model_a] = nil
end

.default_modelObject



39
40
41
42
43
44
# File 'lib/carload/dashboard.rb', line 39

def default_model
  return @@default_model if defined? @@default_model
  @@models.each do |name, spec|
    return @@default_model = name if spec.default
  end
end

.model(name, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/carload/dashboard.rb', line 17

def model name, &block
  if block_given?
    @@models ||= {}
    spec = ModelSpec.new
    yield spec
    @@models[name] = spec
  else
    @@models[name]
  end
end

.modelsObject



35
36
37
# File 'lib/carload/dashboard.rb', line 35

def models
  @@models ||= {}
end