Class: VoteFu::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/vote_fu/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration



29
30
31
32
33
34
35
36
37
38
# File 'lib/vote_fu/configuration.rb', line 29

def initialize
  @allow_recast = true
  @allow_duplicate_votes = false
  @allow_self_vote = false
  @counter_cache = true
  @turbo_broadcasts = true
  @action_cable = true
  @default_ranking = :wilson_score
  @hot_ranking_gravity = 1.8
end

Instance Attribute Details

#action_cableObject

Use ActionCable for real-time updates?



21
22
23
# File 'lib/vote_fu/configuration.rb', line 21

def action_cable
  @action_cable
end

#allow_duplicate_votesObject

Can voters cast multiple votes on the same item?



9
10
11
# File 'lib/vote_fu/configuration.rb', line 9

def allow_duplicate_votes
  @allow_duplicate_votes
end

#allow_recastObject

Can voters change their vote after casting?



6
7
8
# File 'lib/vote_fu/configuration.rb', line 6

def allow_recast
  @allow_recast
end

#allow_self_voteObject

Can a model vote on itself?



12
13
14
# File 'lib/vote_fu/configuration.rb', line 12

def allow_self_vote
  @allow_self_vote
end

#counter_cacheObject

Automatically maintain counter cache columns?



15
16
17
# File 'lib/vote_fu/configuration.rb', line 15

def counter_cache
  @counter_cache
end

#default_rankingObject

Default ranking algorithm (:wilson_score, :reddit_hot, :hacker_news, :simple)



24
25
26
# File 'lib/vote_fu/configuration.rb', line 24

def default_ranking
  @default_ranking
end

#hot_ranking_gravityObject

Gravity parameter for hot ranking algorithms



27
28
29
# File 'lib/vote_fu/configuration.rb', line 27

def hot_ranking_gravity
  @hot_ranking_gravity
end

#turbo_broadcastsObject

Broadcast vote changes via Turbo Streams?



18
19
20
# File 'lib/vote_fu/configuration.rb', line 18

def turbo_broadcasts
  @turbo_broadcasts
end

Instance Method Details

#to_hObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vote_fu/configuration.rb', line 40

def to_h
  {
    allow_recast: allow_recast,
    allow_duplicate_votes: allow_duplicate_votes,
    allow_self_vote: allow_self_vote,
    counter_cache: counter_cache,
    turbo_broadcasts: turbo_broadcasts,
    action_cable: action_cable,
    default_ranking: default_ranking,
    hot_ranking_gravity: hot_ranking_gravity
  }
end