Module: Vectra::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/vectra/config.rb

Defined Under Namespace

Classes: RequiredOptionMissing

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



6
7
8
# File 'lib/vectra/config.rb', line 6

def endpoint
  @endpoint
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/vectra/config.rb', line 6

def password
  @password
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/vectra/config.rb', line 6

def username
  @username
end

Instance Method Details

#from_hash(options = {}) ⇒ Object

Configure vectra from a hash. This is usually called after parsing a yaml config file such as vectra.yaml.

Examples:

Configure Vectra.

config.from_hash({})

Parameters:

  • options (Hash) (defaults to: {})

    The settings to use.



15
16
17
18
19
# File 'lib/vectra/config.rb', line 15

def from_hash(options = {})
  options.each_pair do |name, value|
    send("#{name}=", value) if respond_to?("#{name}=")
  end
end

#load!(path) ⇒ Object

Load the settings from a compliant vectra.yml file. This can be used for easy setup with frameworks other than Rails.

Examples:

Configure Vectra.

Vectra.load!("/path/to/vectra.yml")

Parameters:

  • path (String)

    The path to the file.



28
29
30
31
32
33
# File 'lib/vectra/config.rb', line 28

def load!(path)
  settings = YAML.load(ERB.new(File.new(path).read).result)
  if settings.present?
    from_hash(settings)
  end
end