Module: BallotBox::Base::SingletonMethods

Defined in:
lib/ballot_box/base.rb

Instance Method Summary collapse

Instance Method Details

#ballot_box(options = {}) ⇒ Object

ballot_box :counter_cache => true,

:strategies => [:authenticated],
:place => :position,
:scope => :group_id


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ballot_box/base.rb', line 14

def ballot_box(options = {})
  extend ClassMethods
  include InstanceMethods
  
  default_options = { 
    :strategies => [:authenticated],
    :counter_cache => false, 
    :place => false,
    :refresh => true,
    :scope => nil
  }
  
  options.assert_valid_keys(default_options.keys)
  options = default_options.merge(options)
  
  class_attribute :ballot_box_options, :instance_writer => false
  self.ballot_box_options = options
  
  has_many :votes,
    :class_name => 'BallotBox::Vote', 
    :as => :voteable,
    :dependent => :delete_all
  
  attr_accessor :current_vote
  
  define_ballot_box_callbacks :vote
end