Class: Factor::Connector::ServiceBuilder
- Inherits:
-
Object
- Object
- Factor::Connector::ServiceBuilder
- Defined in:
- lib/builders/service_builder.rb
Instance Method Summary collapse
- #action(id, &block) ⇒ Object
- #build ⇒ Object
-
#initialize(id, &block) ⇒ ServiceBuilder
constructor
A new instance of ServiceBuilder.
- #listener(id, &block) ⇒ Object
Constructor Details
#initialize(id, &block) ⇒ ServiceBuilder
Returns a new instance of ServiceBuilder.
7 8 9 10 11 12 |
# File 'lib/builders/service_builder.rb', line 7 def initialize(id, &block) @listeners = {} @actions = {} @id = id.to_s instance_eval(&block) if block end |
Instance Method Details
#action(id, &block) ⇒ Object
19 20 21 22 |
# File 'lib/builders/service_builder.rb', line 19 def action(id, &block) action = ActionBuilder.new(id, &block).build @actions[action.id] = action end |
#build ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/builders/service_builder.rb', line 24 def build sd = ServiceDefinition.new sd.listeners = @listeners sd.actions = @actions sd.id = @id sd end |
#listener(id, &block) ⇒ Object
14 15 16 17 |
# File 'lib/builders/service_builder.rb', line 14 def listener(id, &block) listener = ListenerBuilder.new(id, &block).build @listeners[listener.id] = listener end |