Module: Streak::Configuration

Included in:
Streak
Defined in:
lib/streak/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#namespaceObject

streak namespace for Redis.

Returns:

  • the streak namespace or the default of ‘streak’ if not set.



52
53
54
# File 'lib/streak/configuration.rb', line 52

def namespace
  @namespace ||= 'streak'
end

#negative_keyObject

Key used in Redis for tracking negative.

Returns:

  • the key used in Redis for tracking negative or the default of ‘losses’ if not set.



80
81
82
# File 'lib/streak/configuration.rb', line 80

def negative_key
  @negative_key ||= 'losses'
end

#negative_streak_keyObject

Key used in Redis for tracking negative streak.

Returns:

  • the key used in Redis for tracking negative streak or the default of ‘losses_streak’ if not set.



94
95
96
# File 'lib/streak/configuration.rb', line 94

def negative_streak_key
  @negative_streak_key ||= 'losses_streak'
end

#negative_total_keyObject

Key used in Redis for tracking negative total.

Returns:

  • the key used in Redis for tracking negative total or the default of ‘losses_total’ if not set.



87
88
89
# File 'lib/streak/configuration.rb', line 87

def negative_total_key
  @negative_total_key ||= 'losses_total'
end

#positive_keyObject

Key used in Redis for tracking positive.

Returns:

  • the key used in Redis for tracking positive or the default of ‘wins’ if not set.



59
60
61
# File 'lib/streak/configuration.rb', line 59

def positive_key
  @positive_key ||= 'wins'
end

#positive_streak_keyObject

Key used in Redis for tracking positive streak.

Returns:

  • the key used in Redis for tracking positive streak or the default of ‘wins_streak’ if not set.



73
74
75
# File 'lib/streak/configuration.rb', line 73

def positive_streak_key
  @positive_streak_key ||= 'wins_streak'
end

#positive_total_keyObject

Key used in Redis for tracking positive total.

Returns:

  • the key used in Redis for tracking positive total or the default of ‘wins_total’ if not set.



66
67
68
# File 'lib/streak/configuration.rb', line 66

def positive_total_key
  @positive_total_key ||= 'wins_total'
end

#redisObject

Redis instance.



4
5
6
# File 'lib/streak/configuration.rb', line 4

def redis
  @redis
end

#total_keyObject

Key used in Redis for tracking totals.

Returns:

  • the key used in Redis for tracking total or the default of ‘total’ if not set.



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

Yields:

  • (_self)

Yield Parameters:



45
46
47
# File 'lib/streak/configuration.rb', line 45

def configure
  yield self
end