Class: Redis::Classy
- Inherits:
-
Object
- Object
- Redis::Classy
- Defined in:
- lib/redis/classy.rb
Class Attribute Summary collapse
-
.db ⇒ Object
Returns the value of attribute db.
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key) ⇒ Classy
constructor
A new instance of Classy.
- #method_missing(method_name, *args, &block) ⇒ Object
Constructor Details
#initialize(key) ⇒ Classy
Returns a new instance of Classy.
23 24 25 |
# File 'lib/redis/classy.rb', line 23 def initialize(key) self.key = key end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
27 28 29 |
# File 'lib/redis/classy.rb', line 27 def method_missing(method_name, *args, &block) self.class.send(method_name, self.key, *args, &block) end |
Class Attribute Details
.db ⇒ Object
Returns the value of attribute db.
4 5 6 |
# File 'lib/redis/classy.rb', line 4 def db @db end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
21 22 23 |
# File 'lib/redis/classy.rb', line 21 def key @key end |
Class Method Details
.inherited(subclass) ⇒ Object
6 7 8 |
# File 'lib/redis/classy.rb', line 6 def inherited(subclass) subclass.db = Redis::Namespace.new(subclass.name, :redis => Redis::Classy.db) end |
.method_missing(method_name, *args, &block) ⇒ Object
10 11 12 |
# File 'lib/redis/classy.rb', line 10 def method_missing(method_name, *args, &block) self.db.send(method_name, *args, &block) end |