class Patriarch::DAOServices::BipartiteRelationshipBuilderService
Patriarch::Transaction
instances are composed of transaction steps that each represent a behaviour being triggered. RelationshipBuilderServices allow Services managing transaction flow to build transaction step correctly. This deals with transaction step needed to represent bipartite behaviours
Public Instance Methods
@param [Patriarch::Transaction] transaction_item Fills current transaction step of the Patriarch::Transaction
argument passed with data needed later to execute transaction. This deals with “DO” behaviour steps
# File lib/patriarch/dao_services/bipartite_relationship_builder_service.rb, line 12 def create(transaction_item) t = Time.now.to_f dao_tab = Patriarch::DAOServices::RetrieverService.instance.call(transaction_item) actor_dao = dao_tab[:actor] target_dao = dao_tab[:target] l = build_struct_for_create(actor_dao,transaction_item.target_id,t) ll = build_struct_for_create(target_dao,transaction_item.actor_id,t) transaction_item.add_to_queue l transaction_item.add_to_queue ll end
@param [Patriarch::Transaction] transaction_item Fills current transaction step of the Patriarch::Transaction
argument passed with data needed later to execute transaction. This deals with “UNDO” behaviour steps
# File lib/patriarch/dao_services/bipartite_relationship_builder_service.rb, line 29 def destroy(transaction_item) dao_tab = Patriarch::DAOServices::RetrieverService.instance.call(transaction_item) actor_dao = dao_tab[:actor] target_dao = dao_tab[:target] l = Patriarch::RedisInstruction.new(actor_dao,:delete,[transaction_item.target_id]) ll = Patriarch::RedisInstruction.new(target_dao,:delete ,[transaction_item.actor_id]) transaction_item.add_to_queue l transaction_item.add_to_queue ll end
Protected Instance Methods
@param [Redis::Objects] dao @param [Array] ids @param [Time] time Returns Patriarch::RedisInstruction
(structs) objects that store parameters to execute a redis operation
# File lib/patriarch/dao_services/bipartite_relationship_builder_service.rb, line 47 def build_struct_for_create(dao,id,time) if dao.is_a? Redis::SortedSet return Patriarch::RedisInstruction.new(dao,:add,[id,time]) else return Patriarch::RedisInstruction.new(dao,:add,[id]) end end