Class: Vanity::Connection::Specification

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

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ Specification

Returns a new instance of Specification.


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

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

  validate_specification_hash(@spec)
end

Instance Method Details

#to_hObject


84
85
86
# File 'lib/vanity/connection.rb', line 84

def to_h
  @spec
end