Class: HotPotato::Route::Routes
- Inherits:
-
Object
- Object
- HotPotato::Route::Routes
- Defined in:
- lib/hot_potato/dsl.rb
Instance Attribute Summary collapse
-
#faucets ⇒ Object
Returns the value of attribute faucets.
-
#sinks ⇒ Object
Returns the value of attribute sinks.
-
#workers ⇒ Object
Returns the value of attribute workers.
Instance Method Summary collapse
- #app_tasks ⇒ Object
- #faucet(classname, options = {}, &block) ⇒ Object
- #find(name) ⇒ Object
-
#initialize ⇒ Routes
constructor
A new instance of Routes.
- #sink(classname, options = {}, &block) ⇒ Object
- #to_s ⇒ Object
- #worker(classname, options = {}, &block) ⇒ Object
Constructor Details
#initialize ⇒ Routes
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
#faucets ⇒ Object
Returns the value of attribute faucets.
58 59 60 |
# File 'lib/hot_potato/dsl.rb', line 58 def faucets @faucets end |
#sinks ⇒ Object
Returns the value of attribute sinks.
58 59 60 |
# File 'lib/hot_potato/dsl.rb', line 58 def sinks @sinks end |
#workers ⇒ Object
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_tasks ⇒ Object
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, = {}, &block) f = Faucet.new(classname, ) 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, = {}, &block) s = Sink.new(classname, ) s.instance_eval(&block) if block @sinks << s end |
#to_s ⇒ Object
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 |