Sha256: ea1f01ed12cca800a22adf85728420be33e49962739d19a996f48d4e96cd330f

Contents?: true

Size: 673 Bytes

Versions: 2

Compression:

Stored size: 673 Bytes

Contents

class Redis
  class Classy
    class << self
      attr_accessor :db

      def inherited(subclass)
        subclass.db = Redis::Namespace.new(subclass.name, :redis => Redis::Classy.db)
      end

      def method_missing(method_name, *args, &block)
        self.db.send(method_name, *args, &block)
      end

      Redis::Namespace::COMMANDS.keys.each do |key|
        define_method(key) do |*args|
          self.db.send(key, *args)
        end
      end
    end

    attr_accessor :key

    def initialize(key)
      self.key = key
    end

    def method_missing(method_name, *args, &block)
      self.class.send(method_name, self.key, *args, &block)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redis-classy-1.1.0 lib/redis/classy.rb
redis-classy-1.0.2 lib/redis/classy.rb