Class: Vigia::Parameters

Inherits:
Object
  • Object
show all
Defined in:
lib/vigia/parameters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters) ⇒ Parameters

Returns a new instance of Parameters.



6
7
8
9
# File 'lib/vigia/parameters.rb', line 6

def initialize(parameters)
  @parameters = parameters
  validate
end

Instance Attribute Details

#parametersObject (readonly)

Returns the value of attribute parameters.



4
5
6
# File 'lib/vigia/parameters.rb', line 4

def parameters
  @parameters
end

Instance Method Details

#to_hashObject



11
12
13
14
15
# File 'lib/vigia/parameters.rb', line 11

def to_hash
  @parameters.each_with_object({}) do |parameter, hash|
    hash.merge!(parameter[:name] => parameter[:value])
  end
end

#validateObject



17
18
19
20
21
# File 'lib/vigia/parameters.rb', line 17

def validate
  return if required_parameters.empty?

  raise("Missing parameters #{ missing_parameters.join(',') }") unless missing_parameters.empty?
end