Class: Red::Base
- Inherits:
-
Object
- Object
- Red::Base
- Defined in:
- lib/red/base.rb
Constant Summary collapse
- @@options =
{}
Class Method Summary collapse
-
.build_options(opts = {}) ⇒ Object
Return a config hash of the default or overridden options merged with passed in hash.
-
.default_options ⇒ Object
Default set of options.
-
.default_options=(vals) ⇒ Object
Assign a default set of options.
Class Method Details
.build_options(opts = {}) ⇒ Object
Return a config hash of the default or overridden options merged with passed in hash
8 9 10 11 |
# File 'lib/red/base.rb', line 8 def (opts = {}) config = @@options.empty? ? self. : @@options config.merge(opts) end |
.default_options ⇒ Object
Default set of options
Everything here is passed to Redis except for :ns, which is the namespace to use for Redis::Namespace
25 26 27 28 29 30 31 32 |
# File 'lib/red/base.rb', line 25 def { :host => '127.0.0.1', :port => 6379, :ns => 'rb', :db => 0 } end |
.default_options=(vals) ⇒ Object
Assign a default set of options
Red.default_options = { :host => …, :port => … }
16 17 18 19 |
# File 'lib/red/base.rb', line 16 def (vals) raise ArgumentError, "#default_options= takes a hash argument" unless vals.is_a?(Hash) @@options = self..merge(vals) end |