Class: Fare::ConfigurationDSL::StackDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/fare/configuration_dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ StackDSL

Returns a new instance of StackDSL.



98
99
100
101
102
# File 'lib/fare/configuration_dsl.rb', line 98

def initialize(configuration)
  @configuration = configuration
  @topics = []
  @run = :not_specified
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



96
97
98
# File 'lib/fare/configuration_dsl.rb', line 96

def configuration
  @configuration
end

Instance Method Details

#listen_to(topic) ⇒ Object



122
123
124
# File 'lib/fare/configuration_dsl.rb', line 122

def listen_to(topic)
  @topics << Topic.new(topic)
end

#parse(&block) ⇒ Object



117
118
119
120
# File 'lib/fare/configuration_dsl.rb', line 117

def parse(&block)
  @source_location = block.source_location
  instance_eval(&block)
end

#run(&block) ⇒ Object



126
127
128
# File 'lib/fare/configuration_dsl.rb', line 126

def run(&block)
  @run = block
end

#to_stackObject



113
114
115
# File 'lib/fare/configuration_dsl.rb', line 113

def to_stack
  SubscriberStack.new(configuration, @topics, @run)
end

#verify!Object



104
105
106
107
108
109
110
111
# File 'lib/fare/configuration_dsl.rb', line 104

def verify!
  if @topics.empty?
    raise "Stack without topics for stack on line #{@source_location.last} of #{@source_location.first}"
  end
  if @run == :not_specified
    raise "No run list specified for stack on line #{@source_location.last} of #{@source_location.first}"
  end
end