Class: CDP::Builders::AfterCreated
- Inherits:
-
Object
- Object
- CDP::Builders::AfterCreated
- Defined in:
- lib/cdp/builders/after_created.rb
Instance Method Summary collapse
- #create_event(target) ⇒ Object
-
#initialize(builder, source) ⇒ AfterCreated
constructor
A new instance of AfterCreated.
- #relate_to(target) ⇒ Object
Constructor Details
#initialize(builder, source) ⇒ AfterCreated
Returns a new instance of AfterCreated.
4 5 6 7 8 9 |
# File 'lib/cdp/builders/after_created.rb', line 4 def initialize(builder, source) raise ArgumentError, 'Unsupported multiple commands' if source.commands.size > 1 raise ArgumentError, 'Only supported on upsert' if source.commands.first&.upsert_entity.blank? @builder = builder @source = source end |
Instance Method Details
#create_event(target) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/cdp/builders/after_created.rb', line 19 def create_event(target) raise ArgumentError, 'Unsupported multiple commands' if target.commands.size > 1 raise ArgumentError, 'Supported only create event' unless target.commands.first&.create_event.present? @source.commands.first.upsert_entity.if_created_create_event << target.commands.first @source end |
#relate_to(target) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/cdp/builders/after_created.rb', line 11 def relate_to(target) raise ArgumentError, 'Unsupported multiple commands' if target.commands.size > 1 raise ArgumentError, 'Supported only create entity' unless target.commands.first&.create_entity.present? @source.commands.first.upsert_entity.if_created_relate_with << target.commands.first @source end |