Class: Patriarch::DAOServices::TripartiteRelationshipBuilderService
- Inherits:
-
Service
- Object
- Service
- Patriarch::DAOServices::TripartiteRelationshipBuilderService
- Defined in:
- lib/patriarch/dao_services/tripartite_relationship_builder_service.rb
Overview
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 tripartite behaviours
Instance Method Summary collapse
-
#create(transaction_item) ⇒ Object
Fills current transaction step of the Patriarch::Transaction argument passed with data needed later to execute transaction.
-
#destroy(transaction_item) ⇒ Object
Fills current transaction step of the Patriarch::Transaction argument passed with data needed later to execute transaction.
Instance Method Details
#create(transaction_item) ⇒ Object
Fills current transaction step of the Patriarch::Transaction argument passed with data needed later to execute transaction. This deals with “DO” behaviour steps
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/patriarch/dao_services/tripartite_relationship_builder_service.rb', line 13 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] medium_dao = dao_tab[:medium] protagonist_ids = [transaction_item.actor_id,transaction_item.target_id,transaction_item.medium_id] l = build_struct_for_create(actor_dao,protagonist_ids,t) ll = build_struct_for_create(target_dao,protagonist_ids,t) lll = build_struct_for_create(medium_dao,protagonist_ids,t) # care about that, should be encapsulated into a beautiful add_to_queue method transaction_item.add_to_queue l transaction_item.add_to_queue ll transaction_item.add_to_queue lll end |
#destroy(transaction_item) ⇒ Object
Fills current transaction step of the Patriarch::Transaction argument passed with data needed later to execute transaction. This deals with “UNDO” behaviour steps
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/patriarch/dao_services/tripartite_relationship_builder_service.rb', line 36 def destroy(transaction_item) dao_tab = Patriarch::DAOServices::RetrieverService.instance.call(transaction_item) actor_dao = dao_tab[:actor] target_dao = dao_tab[:target] medium_dao = dao_tab[:medium] protagonist_ids = [transaction_item.actor_id,transaction_item.target_id,transaction_item.medium_id] #l = lambda { actor_dao.delete protagonist_ids } #ll = lambda { target_dao.delete protagonist_ids } #lll = lambda { medium_dao.delete protagonist_ids } l = Patriarch::RedisInstruction.new(actor_dao ,:delete,[protagonist_ids]) ll = Patriarch::RedisInstruction.new(target_dao,:delete,[protagonist_ids]) lll = Patriarch::RedisInstruction.new(medium_dao,:delete,[protagonist_ids]) transaction_item.add_to_queue l transaction_item.add_to_queue ll transaction_item.add_to_queue lll end |