Module: PollProcess

Defined in:
lib/poll_process.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
7
# File 'lib/poll_process.rb', line 2

def self.included(base)
  base.class_eval {
    alias_method_chain :process, :poll
    attr_accessor :submitted_polls
  }
end

Instance Method Details

#poll_cookies(cookie_hash) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/poll_process.rb', line 9

def poll_cookies(cookie_hash)
  result = []
  cookie_hash.to_a.select { |c| c[0].starts_with?('poll_') }.each do |c|
    result << c[0].gsub('poll_','').to_i
  end
  result
end

#process_with_poll(request, response) ⇒ Object



17
18
19
20
21
# File 'lib/poll_process.rb', line 17

def process_with_poll(request, response)
  # check the cookies and set the polls that have been submitted
  self. = poll_cookies(request.cookies)
  process_without_poll(request, response)
end