module MergingQueue::QueuedTask
Public Instance Methods
publish(data = {})
click to toggle source
Publishes the queued_task to the receivers
@param [ Hash ] options The options to publish with.
# File lib/merging-queue/queued_task.rb, line 114 def publish(data = {}) assign_properties(data) self end
refresh_data()
click to toggle source
# File lib/merging-queue/queued_task.rb, line 121 def refresh_data save(:validate => false) end
Protected Instance Methods
assign_properties(data = {})
click to toggle source
# File lib/merging-queue/queued_task.rb, line 127 def assign_properties(data = {}) self.verb = data.delete(:verb) write_attribute(:publish_on, data[:publish_on]) data.delete(:publish_on) self.state = 'initial' [:actor, :act_object, :act_target].each do |type| cur_object = data[type] unless cur_object if definition.send(type.to_sym) raise verb.to_json #raise MergingQueue::InvalidData.new(type) else next end end class_sym = cur_object.class.name.to_sym raise MergingQueue::InvalidData.new(class_sym) unless definition.send(type) == class_sym case type when :actor self.actor = cur_object when :act_object self.act_object = cur_object when :act_target self.act_target = cur_object else raise "unknown type" end data.delete(type) end [:grouped_actor].each do |group| grp_object = data[group] if grp_object == nil if definition.send(group.to_sym) raise verb.to_json #raise MergingQueue::InvalidData.new(group) else next end end grp_object.each do |cur_obj| raise MergingQueue::InvalidData.new(class_sym) unless definition.send(group) == cur_obj.class.name.to_sym self.grouped_actors << cur_obj end data.delete(group) end cur_bond_type = definition.send(:bond_type) if cur_bond_type write_attribute( :bond_type, cur_bond_type.to_s ) end def_options = definition.send(:options) def_options.each do |cur_option| cur_object = data[cur_option] if cur_object if cur_option == :description self.description = cur_object else options[cur_option] = cur_object end data.delete(cur_option) else #all options defined must be used raise Streama::InvalidData.new(cur_object[0]) end end if data.size > 0 raise "unexpected arguments: " + data.to_json end self.save end
definition()
click to toggle source
# File lib/merging-queue/queued_task.rb, line 231 def definition @definition ||= MergingQueue::Definition.find(verb) end