Class: ForemanDeployments::Validation::ValidationResult
- Inherits:
-
Object
- Object
- ForemanDeployments::Validation::ValidationResult
- Defined in:
- app/lib/foreman_deployments/validation/validation_result.rb
Instance Attribute Summary collapse
-
#messages ⇒ Object
Returns the value of attribute messages.
Instance Method Summary collapse
-
#initialize(messages = {}) ⇒ ValidationResult
constructor
A new instance of ValidationResult.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(messages = {}) ⇒ ValidationResult
6 7 8 9 |
# File 'app/lib/foreman_deployments/validation/validation_result.rb', line 6 def initialize( = {}) fail('messages need to be either hash or array') if !.is_a?(Array) && !.is_a?(Hash) @messages = end |
Instance Attribute Details
#messages ⇒ Object
Returns the value of attribute messages.
4 5 6 |
# File 'app/lib/foreman_deployments/validation/validation_result.rb', line 4 def @messages end |
Instance Method Details
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/lib/foreman_deployments/validation/validation_result.rb', line 15 def to_s if @messages.is_a?(Array) @messages.join("\n") else @messages.collect do |key, | "#{key}: #{}" end.join("\n") end end |
#valid? ⇒ Boolean
11 12 13 |
# File 'app/lib/foreman_deployments/validation/validation_result.rb', line 11 def valid? @messages.empty? end |