Class: Langis::Dsl::IntakeConfig
- Inherits:
-
Object
- Object
- Langis::Dsl::IntakeConfig
- Includes:
- Blockenspiel::DSL
- Defined in:
- lib/langis/dsl.rb
Overview
Dsl config class used to define an intake.
Instance Attribute Summary collapse
-
#sink_type_links ⇒ Hash{String => Set<String>}
readonly
Returns the intake’s configuration mapping between its sinks (names) and the list of types to filter for.
Instance Method Summary collapse
-
#flow_to(*args) ⇒ Object
Dsl only method to define which sinks to propagate a message to.
-
#initialize ⇒ IntakeConfig
constructor
A new instance of IntakeConfig.
Constructor Details
#initialize ⇒ IntakeConfig
Returns a new instance of IntakeConfig.
224 225 226 |
# File 'lib/langis/dsl.rb', line 224 def initialize @sink_type_links = {} end |
Instance Attribute Details
#sink_type_links ⇒ Hash{String => Set<String>} (readonly)
Returns the intake’s configuration mapping between its sinks (names) and the list of types to filter for.
220 221 222 |
# File 'lib/langis/dsl.rb', line 220 def sink_type_links @sink_type_links end |
Instance Method Details
#flow_to(...) ⇒ Object #flow_to(..., options = {}) ⇒ Object
Dsl only method to define which sinks to propagate a message to.
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/langis/dsl.rb', line 244 def flow_to(*args) # Check to see if we have an options hash. Properly pull out the # options, and then make the list of sinks to push to. case args[-1] when Hash = args[-1] sink_names = args[0...-1].map! { |name| name.to_s } else = {} sink_names = args.clone.map! { |name| name.to_s } end # Coerce the message types to handle into an Array of strings case [:when] when Array = [:when].map { |item| item.to_s } when nil # For the nil case, we have an empty array. # The build_pipes method will interpret a sink with an empty set # of types to actually handle all types. = [] else = [ [:when].to_s ] end # We add the types to a Set, one set per sink name. This is for the # multiple intake definitions. sink_names.each do |name| @sink_type_links[name] ||= Set.new @sink_type_links[name].merge end end |