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
|
# File 'lib/ehpt/base.rb', line 9
def initialize(*args)
@data = nil
@errors = []
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
|
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
22
23
24
25
26
27
28
29
30
|
# File 'lib/ehpt/base.rb', line 22
def add_error(error)
if error.is_a?(Array)
error.each do |err|
add_error(err)
end
else
@errors << error
end
end
|
#error? ⇒ Boolean
18
19
20
|
# File 'lib/ehpt/base.rb', line 18
def error?
!success?
end
|
#success? ⇒ Boolean
14
15
16
|
# File 'lib/ehpt/base.rb', line 14
def success?
errors.empty?
end
|