Class: BallotBox::Manager

Inherits:
Object
  • Object
show all
Extended by:
Callbacks
Defined in:
lib/ballot_box/manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Callbacks

_after_vote, _before_vote, after_vote, before_vote

Constructor Details

#initialize(app, options = {}) {|@config| ... } ⇒ Manager

Initialize the middleware. If a block is given, a BallotBox::Config is yielded so you can properly configure the BallotBox::Manager.

Yields:



10
11
12
13
14
15
16
# File 'lib/ballot_box/manager.rb', line 10

def initialize(app, options={})
  options.symbolize_keys!

  @app, @config = app, BallotBox::Config.new(options)
  yield @config if block_given?
  self
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/ballot_box/manager.rb', line 6

def config
  @config
end

Instance Method Details

#_run_callbacks(*args) ⇒ Object

:api: private



27
28
29
# File 'lib/ballot_box/manager.rb', line 27

def _run_callbacks(*args) #:nodoc:
  self.class._run_callbacks(*args)
end

#call(env) ⇒ Object

:nodoc:



18
19
20
21
22
23
24
# File 'lib/ballot_box/manager.rb', line 18

def call(env) # :nodoc:
  if voting_path?(env['PATH_INFO']) && env["REQUEST_METHOD"] == "POST"
    create(env)
  else
    @app.call(env)
  end
end