Class: Protocol::Content::Parameters::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/protocol/content/parameters/result.rb

Overview

The result of parsing and validating content parameters.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, errors) ⇒ Result

Initialize the result.



14
15
16
17
# File 'lib/protocol/content/parameters/result.rb', line 14

def initialize(value, errors)
	@value = value
	@errors = errors.freeze
end

Instance Attribute Details

#errorsObject (readonly)

The validation errors.



23
24
25
# File 'lib/protocol/content/parameters/result.rb', line 23

def errors
  @errors
end

#valueObject (readonly)

The converted and filtered value.



20
21
22
# File 'lib/protocol/content/parameters/result.rb', line 20

def value
  @value
end

Instance Method Details

#[](key) ⇒ Object

Fetch an entry from the result value.



28
29
30
# File 'lib/protocol/content/parameters/result.rb', line 28

def [](key)
	return @value[key]
end

#dig(*path) ⇒ Object

Fetch an entry nested within the result value.



35
36
37
# File 'lib/protocol/content/parameters/result.rb', line 35

def dig(*path)
	return @value.dig(*path)
end

#valid?Boolean

Whether the parameters are valid.

Returns:

  • (Boolean)


41
42
43
# File 'lib/protocol/content/parameters/result.rb', line 41

def valid?
	return @errors.empty?
end