Sha256: f0a1f4a5e4a002a6c5683045ff167c3ce7303fba574fcec611a809c4a8b5ddaa
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 KB
Contents
# This is the class loader, for use as "include Redis::Objects::Sets" # For the object itself, see "Redis::Set" require 'redis/sorted_set' class Redis module Objects module SortedSets def self.included(klass) klass.send :include, InstanceMethods klass.extend ClassMethods end # Class methods that appear in your class when you include Redis::Objects. module ClassMethods # Define a new list. It will function like a regular instance # method, so it can be used alongside ActiveRecord, DataMapper, etc. def sorted_set(name, options={}) redis_objects[name.to_sym] = options.merge(:type => :sorted_set) mod = Module.new do define_method(name) do instance_variable_get("@#{name}") or instance_variable_set("@#{name}", Redis::SortedSet.new( redis_field_key(name), redis_field_redis(name), redis_objects[name.to_sym] ) ) 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 end # Instance methods that appear in your class when you include Redis::Objects. module InstanceMethods end end end end
Version data entries
4 entries across 4 versions & 1 rubygems