Module: Redis::Objects::Lists::ClassMethods
- Defined in:
- lib/redis/objects/lists.rb
Overview
Class methods that appear in your class when you include Redis::Objects.
Instance Method Summary collapse
-
#list(name, options = {}) ⇒ Object
Define a new list.
Instance Method Details
#list(name, options = {}) ⇒ Object
Define a new list. It will function like a regular instance method, so it can be used alongside ActiveRecord, DataMapper, etc.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/redis/objects/lists.rb', line 16 def list(name, ={}) @redis_objects[name.to_sym] = .merge(:type => :list) if [:global] instance_eval <<-EndMethods def #{name} @#{name} ||= Redis::List.new(field_key(:#{name}), redis, @redis_objects[:#{name}]) end EndMethods class_eval <<-EndMethods def #{name} self.class.#{name} end EndMethods else class_eval <<-EndMethods def #{name} @#{name} ||= Redis::List.new(field_key(:#{name}), redis, self.class.redis_objects[:#{name}]) end EndMethods end end |