Class: Auth::Transaction::Event

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
app/models/auth/transaction/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#event_indexObject

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

Returns:

  • (Boolean)


79
80
81
# File 'app/models/auth/transaction/event.rb', line 79

def _completed?
	statuses.last && statuses.last.is_complete?
end

#_failed?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'app/models/auth/transaction/event.rb', line 87

def _failed?
	statuses.last && statuses.last.is_failed?
end

#_processing?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'app/models/auth/transaction/event.rb', line 83

def _processing?
	statuses.last && statuses.last.is_processing?
end

#after_completeObject

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

#argumentsObject

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_objectObject

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_callObject

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_classObject

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_idObject

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_eventsObject

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_committedObject

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

#processObject

@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