Module: PlatformSdk::ActiveRecord::DataPipelineable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/platform_sdk/active_record/data_pipelineable.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #one_roster_pipeline_payload(deleted: false) ⇒ Object
- #pipeline_additional_attributes ⇒ Object
- #pipeline_data(action) ⇒ Object
- #pipeline_excluded_attributes ⇒ Object
- #pipeline_identifiers ⇒ Object
- #pipeline_payload(action) ⇒ Object
- #send_pipeline_create ⇒ Object
- #send_pipeline_destroy ⇒ Object
- #send_pipeline_update ⇒ Object
Class Method Details
.pipeline_meta ⇒ Object
51 52 53 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 51 def self. raise NotImplementedError, 'You must implement the pipeline_meta class method, an example value is { "source": "strongmind-central" }' end |
.pipeline_noun ⇒ Object
47 48 49 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 47 def self.pipeline_noun raise NotImplementedError, 'You must implement the pipeline_noun class method' end |
Instance Method Details
#one_roster_pipeline_payload(deleted: false) ⇒ Object
76 77 78 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 76 def one_roster_pipeline_payload(deleted: false) {} end |
#pipeline_additional_attributes ⇒ Object
72 73 74 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 72 def pipeline_additional_attributes {} end |
#pipeline_data(action) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 65 def pipeline_data(action) attributes.symbolize_keys .merge(pipeline_additional_attributes) .except(*pipeline_excluded_attributes) .merge(action:) end |
#pipeline_excluded_attributes ⇒ Object
55 56 57 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 55 def pipeline_excluded_attributes [] end |
#pipeline_identifiers ⇒ Object
59 60 61 62 63 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 59 def pipeline_identifiers { "id": id } end |
#pipeline_payload(action) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 36 def pipeline_payload(action) { "noun": self.class.pipeline_noun, "identifiers": pipeline_identifiers, "meta": self.class., "data": pipeline_data(action), "envelope_version": '1.0.0', "message_timestamp": Time.current.utc.iso8601 } end |
#send_pipeline_create ⇒ Object
15 16 17 18 19 20 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 15 def send_pipeline_create return if Rails.env.development? Jobs::SendNounToPipelineJob.perform_later(pipeline_payload('created'), one_roster_pipeline_payload) end |
#send_pipeline_destroy ⇒ Object
29 30 31 32 33 34 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 29 def send_pipeline_destroy return if Rails.env.development? Jobs::SendNounToPipelineJob.perform_later(pipeline_payload('destroyed'), one_roster_pipeline_payload(deleted: true)) end |
#send_pipeline_update ⇒ Object
22 23 24 25 26 27 |
# File 'lib/platform_sdk/active_record/data_pipelineable.rb', line 22 def send_pipeline_update return if Rails.env.development? Jobs::SendNounToPipelineJob.perform_later(pipeline_payload('modified'), one_roster_pipeline_payload) end |