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
109 110 111 112 113 114 115 116 |
# File 'lib/taskinator/persistence.rb', line 109 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
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/taskinator/persistence.rb', line 96 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
64 65 66 |
# File 'lib/taskinator/persistence.rb', line 64 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
80 81 82 83 84 85 |
# File 'lib/taskinator/persistence.rb', line 80 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
89 90 91 92 93 |
# File 'lib/taskinator/persistence.rb', line 89 def persist_workflow_state(new_state) Taskinator.redis do |conn| conn.hset(self.key, :state, new_state) end end |
#save ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/taskinator/persistence.rb', line 68 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 |