Class: FatZebra::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/fat_zebra/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/fat_zebra/config.rb', line 29

def self.from_hash(hash)
  c = new
  hash.each do |key, value|
    c.send key, value
  end

  c
end

Instance Method Details

#configObject

Returns the config values in a hash



5
6
7
# File 'lib/fat_zebra/config.rb', line 5

def config
  @config ||= {}
end

#validate!Object

Validates the configuration



20
21
22
23
24
25
26
27
# File 'lib/fat_zebra/config.rb', line 20

def validate!
  @errors = []

  @errors << "Username is required" if self.username.nil?
  @errors << "Token is required" if self.token.nil?

  raise "The following errors were raised during configuration: #{@errors.join(", ")}}" unless @errors.empty?
end