Class: Heroku::Samorau::Check
- Inherits:
-
Object
- Object
- Heroku::Samorau::Check
show all
- Defined in:
- lib/heroku/samorau.rb
Defined Under Namespace
Classes: CheckError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data, screen = NilScreen.new) ⇒ Check
Returns a new instance of Check.
68
69
70
71
|
# File 'lib/heroku/samorau.rb', line 68
def initialize(data, screen=NilScreen.new)
@data = data
@screen = screen
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
64
65
66
|
# File 'lib/heroku/samorau.rb', line 64
def data
@data
end
|
#screen ⇒ Object
Returns the value of attribute screen.
64
65
66
|
# File 'lib/heroku/samorau.rb', line 64
def screen
@screen
end
|
Instance Method Details
#call ⇒ Object
95
96
97
98
99
100
101
102
103
|
# File 'lib/heroku/samorau.rb', line 95
def call
call!
true
rescue CheckError => boom
screen.result(false)
screen.error boom.message if boom.message != boom.class.name
false
end
|
#check(msg) ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'lib/heroku/samorau.rb', line 77
def check(msg)
screen.check(msg)
if yield
screen.result(true)
else
raise CheckError
end
end
|
#error(msg) ⇒ Object
91
92
93
|
# File 'lib/heroku/samorau.rb', line 91
def error(msg)
raise CheckError, msg
end
|
#run(klass, data) ⇒ Object
86
87
88
89
|
# File 'lib/heroku/samorau.rb', line 86
def run(klass, data)
c = klass.new(data, screen)
instance_eval(&c)
end
|
#test(msg) ⇒ Object
73
74
75
|
# File 'lib/heroku/samorau.rb', line 73
def test(msg)
screen.test msg
end
|
#to_proc ⇒ Object
105
106
107
108
|
# File 'lib/heroku/samorau.rb', line 105
def to_proc
me = self
Proc.new { me.call! }
end
|