Sha256: 4d68f2a39c7a86baf33c3e0e755c2da2412537d3799c4d7346cfb8ce187b354b

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 Bytes

Contents

module Redisrank
  module Options

    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def option_accessor(*opts)
        opts.each do |option|
          define_method(option) do |*args|
            if !args.first.nil?
              options[option.to_sym] = args.first
            else
              options[option.to_sym] || nil
            end
          end
        end
      end
    end

    def parse_options(opts)
      opts ||= {}
      @raw_options = opts
      @options = default_options.merge(opts.reject { |k,v| v.nil? })
    end

    def default_options
      {}
    end

    def options
      @options ||= {}
    end

    def raw_options
      @raw_options ||= {}
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redisrank-0.1.0 lib/redisrank/mixins/options.rb