Class: TinyConveyor::Parcel
- Inherits:
-
Object
- Object
- TinyConveyor::Parcel
- Defined in:
- lib/tiny_conveyor/parcel.rb
Overview
Encapsulate an action to run in a separated thread
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(name, description, action) ⇒ Parcel
constructor
Newly created parcel.
-
#running? ⇒ boolean
True if the parcel is executed, false otherwhise.
Constructor Details
#initialize(name, description, action) ⇒ Parcel
Returns newly created parcel.
13 14 15 16 17 18 19 |
# File 'lib/tiny_conveyor/parcel.rb', line 13 def initialize(name, description, action) @name = name @description = description @action = action @state = :pending @uuid = SecureRandom.uuid end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/tiny_conveyor/parcel.rb', line 7 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/tiny_conveyor/parcel.rb', line 7 def name @name end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/tiny_conveyor/parcel.rb', line 7 def state @state end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
7 8 9 |
# File 'lib/tiny_conveyor/parcel.rb', line 7 def uuid @uuid end |
Instance Method Details
#execute ⇒ Object
21 22 23 24 |
# File 'lib/tiny_conveyor/parcel.rb', line 21 def execute @state = :running @action.call end |
#running? ⇒ boolean
Returns true if the parcel is executed, false otherwhise.
27 28 29 |
# File 'lib/tiny_conveyor/parcel.rb', line 27 def running? @state == :running end |