Class: Ehpt::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/ehpt/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Base
Returns a new instance of Base.
9
10
11
12
13
|
# File 'lib/ehpt/base.rb', line 9
def initialize(*args)
@data = nil
@errors = []
@warnings = []
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3
4
5
|
# File 'lib/ehpt/base.rb', line 3
def data
@data
end
|
#errors ⇒ Object
Returns the value of attribute errors.
3
4
5
|
# File 'lib/ehpt/base.rb', line 3
def errors
@errors
end
|
#warnings ⇒ Object
Returns the value of attribute warnings.
3
4
5
|
# File 'lib/ehpt/base.rb', line 3
def warnings
@warnings
end
|
Class Method Details
.call(*args) ⇒ Object
5
6
7
|
# File 'lib/ehpt/base.rb', line 5
def self.call(*args)
new(*args).call
end
|
Instance Method Details
#add_error(error) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/ehpt/base.rb', line 27
def add_error(error)
if error.is_a?(Array)
error.each do |err|
add_error(err)
end
else
@errors << error
end
end
|
#add_warning(warning) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/ehpt/base.rb', line 37
def add_warning(warning)
if warning.is_a?(Array)
warning.each do |err|
add_warning(err)
end
else
@warnings << warning
end
end
|
#error? ⇒ Boolean
19
20
21
|
# File 'lib/ehpt/base.rb', line 19
def error?
!success?
end
|
#success? ⇒ Boolean
15
16
17
|
# File 'lib/ehpt/base.rb', line 15
def success?
errors.empty?
end
|
#warning? ⇒ Boolean
23
24
25
|
# File 'lib/ehpt/base.rb', line 23
def warning?
!warnings.empty?
end
|