Module: Streak::Configuration
- Included in:
- Streak
- Defined in:
- lib/streak/configuration.rb
Instance Attribute Summary collapse
-
#namespace ⇒ Object
streak namespace for Redis.
-
#negative_key ⇒ Object
Key used in Redis for tracking negative.
-
#negative_streak_key ⇒ Object
Key used in Redis for tracking negative streak.
-
#negative_total_key ⇒ Object
Key used in Redis for tracking negative total.
-
#positive_key ⇒ Object
Key used in Redis for tracking positive.
-
#positive_streak_key ⇒ Object
Key used in Redis for tracking positive streak.
-
#positive_total_key ⇒ Object
Key used in Redis for tracking positive total.
-
#redis ⇒ Object
Redis instance.
-
#total_key ⇒ Object
Key used in Redis for tracking totals.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Yield self to be able to configure Streak with block-style configuration.
Instance Attribute Details
#namespace ⇒ Object
streak namespace for Redis.
52 53 54 |
# File 'lib/streak/configuration.rb', line 52 def namespace @namespace ||= 'streak' end |
#negative_key ⇒ Object
Key used in Redis for tracking negative.
80 81 82 |
# File 'lib/streak/configuration.rb', line 80 def negative_key @negative_key ||= 'losses' end |
#negative_streak_key ⇒ Object
Key used in Redis for tracking negative streak.
94 95 96 |
# File 'lib/streak/configuration.rb', line 94 def negative_streak_key @negative_streak_key ||= 'losses_streak' end |
#negative_total_key ⇒ Object
Key used in Redis for tracking negative total.
87 88 89 |
# File 'lib/streak/configuration.rb', line 87 def negative_total_key @negative_total_key ||= 'losses_total' end |
#positive_key ⇒ Object
Key used in Redis for tracking positive.
59 60 61 |
# File 'lib/streak/configuration.rb', line 59 def positive_key @positive_key ||= 'wins' end |
#positive_streak_key ⇒ Object
Key used in Redis for tracking positive streak.
73 74 75 |
# File 'lib/streak/configuration.rb', line 73 def positive_streak_key @positive_streak_key ||= 'wins_streak' end |
#positive_total_key ⇒ Object
Key used in Redis for tracking positive total.
66 67 68 |
# File 'lib/streak/configuration.rb', line 66 def positive_total_key @positive_total_key ||= 'wins_total' end |
#redis ⇒ Object
Redis instance.
4 5 6 |
# File 'lib/streak/configuration.rb', line 4 def redis @redis end |
#total_key ⇒ Object
Key used in Redis for tracking totals.
101 102 103 |
# File 'lib/streak/configuration.rb', line 101 def total_key @total_key ||= 'total' end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Yield self to be able to configure Streak with block-style configuration.
Example:
Streak.configure do |configuration|
configuration.redis = Redis.new
configuration.namespace = 'streak'
configuration.positive_key = 'wins'
configuration.positive_total_key = 'wins_total'
configuration.positive_streak_key = 'wins_streak'
configuration.negative_key = 'losses'
configuration.negative_total_key = 'losses_total'
configuration.negative_streak_key = 'losses_streak'
configuration.total_key = 'total'
end
45 46 47 |
# File 'lib/streak/configuration.rb', line 45 def configure yield self end |