Class: Mengpaneel::Flusher

Inherits:
Object
  • Object
show all
Defined in:
lib/mengpaneel/flusher.rb

Constant Summary collapse

STRATEGIES =
[
  Strategy::Delayed,
  Strategy::ClientSide,
  Strategy::CapableClientSide,
  Strategy::AsyncServerSide,
  Strategy::ServerSide
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manager) ⇒ Flusher

Returns a new instance of Flusher.



19
20
21
# File 'lib/mengpaneel/flusher.rb', line 19

def initialize(manager)
  @manager = manager
end

Instance Attribute Details

#managerObject (readonly)

Returns the value of attribute manager.



17
18
19
# File 'lib/mengpaneel/flusher.rb', line 17

def manager
  @manager
end

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/mengpaneel/flusher.rb', line 23

def run
  return unless Mengpaneel.token
  
  if manager.flushing_strategy
    strategy = Strategy.const_get(manager.flushing_strategy.to_s.classify)
    flush_using(strategy)
  else
    STRATEGIES.find { |strategy| flush_using(strategy) }
  end
end