module Redis::Objects::Lists::ClassMethods
Class methods that appear in your class when you include Redis::Objects
.
Public Instance Methods
list(name, options={})
click to toggle source
Define a new list. It will function like a regular instance method, so it can be used alongside ActiveRecord, DataMapper, etc.
# File lib/redis/objects/lists.rb, line 16 def list(name, options={}) redis_objects[name.to_sym] = options.merge(:type => :list) ivar_name = :"@#{name}" mod = Module.new do define_method(name) do instance_variable_get(ivar_name) or instance_variable_set(ivar_name, Redis::List.new( redis_field_key(name), redis_field_redis(name), redis_options(name) ) ) end define_method(:"#{name}=") do |values| list = public_send(name) redis.pipelined do list.clear list.push(*values) end end end if options[:global] extend mod # dispatch to class methods define_method(name) do self.class.public_send(name) end else include mod end end