Sha256: f1fb0ff9d8d774dee3a564d2bd3f6450f4d094a2118ab7420a657b06e27b0587

Contents?: true

Size: 970 Bytes

Versions: 1

Compression:

Stored size: 970 Bytes

Contents

# frozen_string_literal: true

module Followability
  module Followable
    module Callbacks
      METHOD_NAMES = %i[
        follow_request_sent_to_someone
        follow_request_sent_to_me
        follow_request_accepted_by_me
        follow_request_accepted_by_someone
        follow_request_declined_by_me
        follow_request_declined_by_someone
        follow_request_removed_by_me
        follow_request_removed_by_someone
        followable_blocked_by_me
        followable_blocked_by_someone
        followable_unblocked_by_me
        followable_unblocked_by_someone
        followability_triggered
      ].freeze

      def run_callback(record, callback:, affected:)
        raise ArgumentError if METHOD_NAMES.exclude?(callback) || callback.eql?(:followability_triggered)

        [callback, :followability_triggered].each do |cb_name|
          record.send(cb_name, affected, cb_name) if record.respond_to?(cb_name)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
followability-1.0.0 lib/followability/followable/callbacks.rb