Class: HotPotato::Route::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/hot_potato/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRoutes

Returns a new instance of Routes.



60
61
62
63
64
# File 'lib/hot_potato/dsl.rb', line 60

def initialize
  @faucets = []
  @workers = []
  @sinks = []      
end

Instance Attribute Details

#faucetsObject

Returns the value of attribute faucets.



58
59
60
# File 'lib/hot_potato/dsl.rb', line 58

def faucets
  @faucets
end

#sinksObject

Returns the value of attribute sinks.



58
59
60
# File 'lib/hot_potato/dsl.rb', line 58

def sinks
  @sinks
end

#workersObject

Returns the value of attribute workers.



58
59
60
# File 'lib/hot_potato/dsl.rb', line 58

def workers
  @workers
end

Instance Method Details

#app_tasksObject



75
76
77
# File 'lib/hot_potato/dsl.rb', line 75

def app_tasks
  @faucets + @workers + @sinks
end

#faucet(classname, options = {}, &block) ⇒ Object



79
80
81
82
83
# File 'lib/hot_potato/dsl.rb', line 79

def faucet(classname, options = {}, &block)
  f = Faucet.new(classname, options)      
  f.instance_eval(&block) if block
  @faucets << f
end

#find(name) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/hot_potato/dsl.rb', line 66

def find(name)
  app_tasks.each do |app_task|
    if app_task.classname.to_s == name.to_s
      return app_task
    end
  end
  return nil
end

#sink(classname, options = {}, &block) ⇒ Object



91
92
93
94
95
# File 'lib/hot_potato/dsl.rb', line 91

def sink(classname, options = {}, &block)
  s = Sink.new(classname, options)      
  s.instance_eval(&block) if block
  @sinks << s
end

#to_sObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/hot_potato/dsl.rb', line 97

def to_s
  str = "Faucets\n"
  @faucets.each do |f|
    str << f.to_s
  end
  str << "Workers\n"
  @workers.each do |f|
    str << f.to_s
  end
  str << "Sinks\n"
  @sinks.each do |f|
    str << f.to_s
  end
  str
end

#worker(classname, options = {}, &block) ⇒ Object



85
86
87
88
89
# File 'lib/hot_potato/dsl.rb', line 85

def worker(classname, options = {}, &block)
  w = Worker.new(classname, options)      
  w.instance_eval(&block) if block
  @workers << w
end