Class: Auth::Transaction::Event
- Inherits:
-
Object
- Object
- Auth::Transaction::Event
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/auth/transaction/event.rb
Instance Attribute Summary collapse
-
#event_index ⇒ Object
Returns the value of attribute event_index.
Instance Method Summary collapse
- #_completed? ⇒ Boolean
- #_failed? ⇒ Boolean
- #_processing? ⇒ Boolean
-
#after_complete ⇒ Object
validate numericality and range, between 0 and 1.
-
#arguments ⇒ Object
arguments is an array of hashes.
-
#get_object ⇒ Object
here we will have a problem with nested objects.
-
#method_to_call ⇒ Object
the method that has to be called on the object class.
-
#object_class ⇒ Object
the object class to instantiate the object id from.
-
#object_id ⇒ Object
id of the object.
-
#output_events ⇒ Object
array of hashes of event objects like : [object_class, object_id, arguments:,object_class, object_id, arguments:] these should be committed into the event at the same t.
-
#output_events_committed ⇒ Object
were the output events committed ? so that we don’t do it twice :).
-
#process ⇒ Object
@return array of Auth::Transaction::Event objects.
Instance Attribute Details
#event_index ⇒ Object
Returns the value of attribute event_index.
9 10 11 |
# File 'app/models/auth/transaction/event.rb', line 9 def event_index @event_index end |
Instance Method Details
#_completed? ⇒ Boolean
79 80 81 |
# File 'app/models/auth/transaction/event.rb', line 79 def _completed? statuses.last && statuses.last.is_complete? end |
#_failed? ⇒ Boolean
87 88 89 |
# File 'app/models/auth/transaction/event.rb', line 87 def _failed? statuses.last && statuses.last.is_failed? end |
#_processing? ⇒ Boolean
83 84 85 |
# File 'app/models/auth/transaction/event.rb', line 83 def _processing? statuses.last && statuses.last.is_processing? end |
#after_complete ⇒ Object
validate numericality and range, between 0 and 1.
13 |
# File 'app/models/auth/transaction/event.rb', line 13 field :after_complete, type: Integer, default: 0 |
#arguments ⇒ Object
arguments is an array of hashes. the method has to know what to do with them.
52 |
# File 'app/models/auth/transaction/event.rb', line 52 field :arguments, type: Hash |
#get_object ⇒ Object
here we will have a problem with nested objects. and will have to provide a better way to query this.
70 71 72 73 74 75 76 77 |
# File 'app/models/auth/transaction/event.rb', line 70 def get_object begin self.object_class.constantize.find(object_id) rescue Mongoid::Errors::DocumentNotFound puts "could not find the document." nil end end |
#method_to_call ⇒ Object
the method that has to be called on the object class
29 |
# File 'app/models/auth/transaction/event.rb', line 29 field :method_to_call, type: String |
#object_class ⇒ Object
the object class to instantiate the object id from.
33 |
# File 'app/models/auth/transaction/event.rb', line 33 field :object_class, type: String |
#object_id ⇒ Object
id of the object. should be a valid bson::objectid
39 |
# File 'app/models/auth/transaction/event.rb', line 39 field :object_id, type: String |
#output_events ⇒ Object
array of hashes of event objects like : [object_class, object_id, arguments:,object_class, object_id, arguments:] these should be committed into the event at the same t
21 |
# File 'app/models/auth/transaction/event.rb', line 21 field :output_events, type: Array, default: [] |
#output_events_committed ⇒ Object
were the output events committed ? so that we don’t do it twice :)
26 |
# File 'app/models/auth/transaction/event.rb', line 26 field :output_events_committed, type: Boolean |
#process ⇒ Object
@return array of Auth::Transaction::Event objects. or nil, in case the #object_id of this event cannot be found.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/models/auth/transaction/event.rb', line 56 def process if self.object_id return nil unless get_object #puts "the get object is:" #puts get_object.to_s self.output_events = get_object.send(method_to_call,arguments) else self.output_events = self.object_class.constantize.send(method_to_call,arguments) end self.output_events end |