Module: Strum::Pipeline::ClassMethods

Defined in:
lib/strum/pipeline.rb

Overview

class methods

Instance Method Summary collapse

Instance Method Details

#bind_to_pipeline(value) ⇒ Object



72
73
74
# File 'lib/strum/pipeline.rb', line 72

def bind_to_pipeline(value)
  Strum::Pipeline.config.bind_to_pipeline = value
end

#init(message_type, message_binding, handler = nil) ⇒ Object



80
81
82
83
# File 'lib/strum/pipeline.rb', line 80

def init(message_type, message_binding, handler = nil)
  bind_to(pipeline_name, message_type, message_binding, handler) if Strum::Pipeline.config.bind_to_pipeline
  inits << handler_key(message_type, message_binding)
end

#initsObject



76
77
78
# File 'lib/strum/pipeline.rb', line 76

def inits
  @inits ||= []
end

#pipeline_nameObject



96
97
98
99
100
101
102
103
104
# File 'lib/strum/pipeline.rb', line 96

def pipeline_name
  word = name.dup
  word.gsub!(/::/, "_")
  word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
  word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
  word.tr!("-", "_")
  word.downcase!
  word
end

#step(message_type, message_binding, handler = nil) ⇒ Object



85
86
87
88
89
90
91
92
93
94
# File 'lib/strum/pipeline.rb', line 85

def step(message_type, message_binding, handler = nil)
  return unless Strum::Pipeline.config.bind_to_pipeline

  bind_to(pipeline_name, message_type, message_binding, handler) do |bindings|
    bindings[:pipeline] ||= {}
    bindings[:pipeline][:name] = pipeline_name
    bindings[:pipeline][message_type] ||= []
    bindings[:pipeline][message_type] << message_binding
  end
end

#ttl(interval) ⇒ Object



68
69
70
# File 'lib/strum/pipeline.rb', line 68

def ttl(interval)
  Strum::Pipeline.config.ttl = interval
end