Class: Vigia::Parameters
- Inherits:
-
Object
- Object
- Vigia::Parameters
- Defined in:
- lib/vigia/parameters.rb
Instance Attribute Summary collapse
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Instance Method Summary collapse
-
#initialize(parameters) ⇒ Parameters
constructor
A new instance of Parameters.
- #to_hash ⇒ Object
- #validate ⇒ Object
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
#parameters ⇒ Object (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_hash ⇒ Object
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 |
#validate ⇒ Object
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 |