Module: Spinel::Config
- Included in:
- Spinel
- Defined in:
- lib/spinel/config.rb
Constant Summary collapse
- DEFAULT_MIN_COMPLETE =
2
- DEFAULT_CACHE_EXPIRE =
600
- DEFAULT_MATCH_LIMIT =
10
- DEFAULT_DOCUMENT_KEY =
:body
- DEFAULT_NAMESPACE =
'spinel'
Instance Attribute Summary collapse
- #cache_expire ⇒ Object
- #document_key ⇒ Object
- #match_limit ⇒ Object
- #min_complete ⇒ Object
- #namespace ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#cache_expire ⇒ Object
15 16 17 |
# File 'lib/spinel/config.rb', line 15 def cache_expire @cache_expire ||= DEFAULT_CACHE_EXPIRE end |
#document_key ⇒ Object
23 24 25 |
# File 'lib/spinel/config.rb', line 23 def document_key (@document_key ||= DEFAULT_DOCUMENT_KEY).to_s end |
#match_limit ⇒ Object
19 20 21 |
# File 'lib/spinel/config.rb', line 19 def match_limit @match_limit ||= DEFAULT_MATCH_LIMIT end |
#min_complete ⇒ Object
11 12 13 |
# File 'lib/spinel/config.rb', line 11 def min_complete @min_complete ||= DEFAULT_MIN_COMPLETE end |
#namespace ⇒ Object
27 28 29 |
# File 'lib/spinel/config.rb', line 27 def namespace @namespace ||= DEFAULT_NAMESPACE end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
55 56 57 58 |
# File 'lib/spinel/config.rb', line 55 def configure yield self self end |
#redis ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/spinel/config.rb', line 42 def redis @redis ||= ( url = URI(@redis_url || ENV["REDIS_URL"] || "redis://127.0.0.1:6379/0") ::Redis.new({ host: url.host, port: url.port, db: url.path[1..-1], password: url.password }) ) end |
#redis=(server) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/spinel/config.rb', line 31 def redis=(server) if server.is_a?(String) @redis = nil @redis_url = server else @redis = server end redis end |