Module: Taskinator::Persistence::InstanceMethods
- Defined in:
- lib/taskinator/persistence.rb
Instance Method Summary collapse
-
#error ⇒ Object
retrieves the error type, message and backtrace and returns an array with 3 subscripts respectively.
-
#fail(error) ⇒ Object
persists the error information.
- #key ⇒ Object
-
#load_workflow_state ⇒ Object
retrieves the workflow state this method is called from the workflow gem.
-
#persist_workflow_state(new_state) ⇒ Object
persists the workflow state this method is called from the workflow gem.
- #save ⇒ Object
Instance Method Details
#error ⇒ Object
retrieves the error type, message and backtrace and returns an array with 3 subscripts respectively
97 98 99 100 101 102 103 104 |
# File 'lib/taskinator/persistence.rb', line 97 def error @error ||= Taskinator.redis do |conn| error_type, , error_backtrace = conn.hmget(self.key, :error_type, :error_message, :error_backtrace) [error_type, , JSON.parse(error_backtrace)] end end |
#fail(error) ⇒ Object
persists the error information
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/taskinator/persistence.rb', line 84 def fail(error) Taskinator.redis do |conn| conn.hmset( self.key, :error_type, error.class.name, :error_message, error., :error_backtrace, JSON.generate(error.backtrace) ) end end |
#key ⇒ Object
52 53 54 |
# File 'lib/taskinator/persistence.rb', line 52 def key self.class.key_for(self.uuid) end |
#load_workflow_state ⇒ Object
retrieves the workflow state this method is called from the workflow gem
68 69 70 71 72 73 |
# File 'lib/taskinator/persistence.rb', line 68 def load_workflow_state state = Taskinator.redis do |conn| conn.hget(self.key, :state) end (state || 'initial').to_sym end |
#persist_workflow_state(new_state) ⇒ Object
persists the workflow state this method is called from the workflow gem
77 78 79 80 81 |
# File 'lib/taskinator/persistence.rb', line 77 def persist_workflow_state(new_state) Taskinator.redis do |conn| conn.hset(self.key, :state, new_state) end end |
#save ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/taskinator/persistence.rb', line 56 def save Taskinator.redis do |conn| conn.multi do RedisSerializationVisitor.new(conn, self).visit conn.sadd "taskinator:#{self.class.base_key}", self.uuid true end end end |