class Brpoplpush::RedisScript::Config

Class holding gem configuration

@author Mikael Henriksson <mikael@mhenrixon.com>

Attributes

logger[R]

@!attribute [r] logger

@return [Logger] a logger to use for debugging
scripts_path[R]

@!attribute [r] scripts_path

@return [Pathname] a directory with lua scripts

Public Class Methods

new() click to toggle source

Initialize a new instance of {Config}

# File lib/brpoplpush/redis_script/config.rb, line 23
def initialize
  @conn         = Redis.new
  @logger       = Logger.new($stdout)
  @scripts_path = nil
end

Public Instance Methods

logger=(obj) click to toggle source

Sets a value for logger

@param [Logger] obj a logger to use

@raise [ArgumentError] when given argument isn't a Logger

@return [Logger]

# File lib/brpoplpush/redis_script/config.rb, line 61
def logger=(obj)
  raise ArgumentError, "#{obj} should be a Logger" unless obj.is_a?(Logger)

  @logger = obj
end
scripts_path=(obj) click to toggle source

Sets a value for scripts_path

@param [String, Pathname] obj <description>

@raise [ArgumentError] when directory does not exist @raise [ArgumentError] when argument isn't supported

@return [Pathname]

# File lib/brpoplpush/redis_script/config.rb, line 39
def scripts_path=(obj)
  raise ArgumentError, "#{obj} should be a Pathname or String" unless obj.is_a?(Pathname) || obj.is_a?(String)
  raise ArgumentError, "#{obj} does not exist" unless Dir.exist?(obj.to_s)

  @scripts_path =
    case obj
    when String
      Pathname.new(obj)
    else
      obj
    end
end