Class: Amberletters::TimeoutTrigger
- Defined in:
- lib/amberletters.rb
Instance Attribute Summary collapse
-
#expiration_time ⇒ Object
readonly
Returns the value of attribute expiration_time.
Attributes inherited from Trigger
#exclusive, #interruption, #logger, #options, #time_to_live
Instance Method Summary collapse
- #call(process) ⇒ Object
-
#initialize(expiration_time = Time.now+1.0, options = {}, &block) ⇒ TimeoutTrigger
constructor
A new instance of TimeoutTrigger.
- #to_s ⇒ Object
Constructor Details
#initialize(expiration_time = Time.now+1.0, options = {}, &block) ⇒ TimeoutTrigger
Returns a new instance of TimeoutTrigger.
159 160 161 162 163 164 165 |
# File 'lib/amberletters.rb', line 159 def initialize(expiration_time=Time.now+1.0, ={}, &block) super(, &block) @expiration_time = case expiration_time when Time then expiration_time when Numeric then Time.now + expiration_time end end |
Instance Attribute Details
#expiration_time ⇒ Object (readonly)
Returns the value of attribute expiration_time.
157 158 159 |
# File 'lib/amberletters.rb', line 157 def expiration_time @expiration_time end |
Instance Method Details
#call(process) ⇒ Object
171 172 173 174 175 176 177 178 |
# File 'lib/amberletters.rb', line 171 def call(process) if process.time >= expiration_time @block.call(self, process, process.blocker) true else false end end |
#to_s ⇒ Object
167 168 169 |
# File 'lib/amberletters.rb', line 167 def to_s "timeout at #{expiration_time}" end |