Class: SandthornSequelProjection::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/sandthorn_sequel_projection/runner.rb

Constant Summary collapse

DEFAULT_INTERVAL =
0.5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest, interval = DEFAULT_INTERVAL) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
# File 'lib/sandthorn_sequel_projection/runner.rb', line 8

def initialize(manifest, interval = DEFAULT_INTERVAL)
  @manifest = manifest
  @interval = interval
end

Instance Attribute Details

#intervalObject (readonly)

Returns the value of attribute interval.



6
7
8
# File 'lib/sandthorn_sequel_projection/runner.rb', line 6

def interval
  @interval
end

#manifestObject (readonly)

Returns the value of attribute manifest.



6
7
8
# File 'lib/sandthorn_sequel_projection/runner.rb', line 6

def manifest
  @manifest
end

Instance Method Details

#run(infinite = true) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sandthorn_sequel_projection/runner.rb', line 13

def run(infinite = true)
  @projections = manifest.projections.map do |projection_class|
    projection_class.new(db_connection)
  end
  migrate!
  if infinite
    start_loop
  else
    loop_once
  end
end