Class: Vanity::Connection::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/vanity/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ Specification


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/vanity/connection.rb', line 66

def initialize(spec)
  case spec
  when String
    @spec = build_specification_hash_from_url(spec)
  when Hash
    if spec[:redis]
      @spec = {
        adapter: :redis,
        redis: spec[:redis]
      }
    else
      @spec = spec
    end
  else
    raise InvalidSpecification.new("Unsupported connection specification: #{spec.inspect}")
  end

  validate_specification_hash(@spec)
end

Instance Method Details

#to_hObject


86
87
88
# File 'lib/vanity/connection.rb', line 86

def to_h
  @spec
end