Sha256: 44e7b6e47754ace0dbfcd5ad678e18f61f50647626d703894a7ac34ff42ddf9d

Contents?: true

Size: 732 Bytes

Versions: 85

Compression:

Stored size: 732 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/events"
require "attr_extras"

module Renalware
  module Events
    # A wrapper around the creation of an Event to allow is to broadcast a Wisper event to the
    # 'world' (or rather just whoever has been configured in the broadcast subscription map).
    class CreateEvent
      include Broadcasting
      pattr_initialize [:event!, :by!]

      # Returns the boolean result of event.save_by
      def self.call(**args)
        new(**args)
          .broadcasting_to_configured_subscribers
          .call
      end

      def call
        event.save_by(by).tap do |success|
          broadcast(:event_created, event) if success
        end
      end
    end
  end
end

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
renalware-core-2.0.159 app/models/renalware/events/create_event.rb
renalware-core-2.0.158 app/models/renalware/events/create_event.rb
renalware-core-2.0.157 app/models/renalware/events/create_event.rb
renalware-core-2.0.156 app/models/renalware/events/create_event.rb
renalware-core-2.0.155 app/models/renalware/events/create_event.rb
renalware-core-2.0.153 app/models/renalware/events/create_event.rb
renalware-core-2.0.152 app/models/renalware/events/create_event.rb
renalware-core-2.0.151 app/models/renalware/events/create_event.rb
renalware-core-2.0.149 app/models/renalware/events/create_event.rb
renalware-core-2.0.148 app/models/renalware/events/create_event.rb
renalware-core-2.0.147 app/models/renalware/events/create_event.rb
renalware-core-2.0.146 app/models/renalware/events/create_event.rb
renalware-core-2.0.145 app/models/renalware/events/create_event.rb
renalware-core-2.0.144 app/models/renalware/events/create_event.rb
renalware-core-2.0.143 app/models/renalware/events/create_event.rb
renalware-core-2.0.142 app/models/renalware/events/create_event.rb
renalware-core-2.0.141 app/models/renalware/events/create_event.rb
renalware-core-2.0.140 app/models/renalware/events/create_event.rb
renalware-core-2.0.139 app/models/renalware/events/create_event.rb
renalware-core-2.0.138 app/models/renalware/events/create_event.rb