Module: Soulheart::Config
- Included in:
- Soulheart
- Defined in:
- lib/soulheart/config.rb
Constant Summary collapse
- DEFAULT_STOP_WORDS =
%w(vs at the)
Instance Method Summary collapse
-
#redis ⇒ Object
Returns the current Redis connection.
-
#redis=(server) ⇒ Object
Accepts: 1.
- #stop_words ⇒ Object
- #stop_words=(arr) ⇒ Object
Instance Method Details
#redis ⇒ Object
Returns the current Redis connection. If none has been created, will create a new one.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/soulheart/config.rb', line 24 def redis @redis ||= ( url = URI(@redis_url || ENV['REDIS_URL'] || 'redis://127.0.0.1:6379/0') ::Redis.new( # driver: :hiredis, host: url.host, port: url.port, db: url.path[1..-1], password: url.password) ) end |
#redis=(server) ⇒ Object
Accepts:
1. A Redis URL String 'redis://host:port/db'
2. An existing instance of Redis, Redis::Namespace, etc.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/soulheart/config.rb', line 11 def redis=(server) if server.is_a?(String) @redis = nil @redis_url = server else @redis = server end redis end |
#stop_words ⇒ Object
35 36 37 |
# File 'lib/soulheart/config.rb', line 35 def stop_words @stop_words ||= DEFAULT_STOP_WORDS end |
#stop_words=(arr) ⇒ Object
39 40 41 |
# File 'lib/soulheart/config.rb', line 39 def stop_words=(arr) @stop_words = Array(arr).flatten end |