Sha256: aebb9518a6ce22296bf87205bec69398c0306165ae42458f183fa3840bea5a1c

Contents?: true

Size: 898 Bytes

Versions: 7

Compression:

Stored size: 898 Bytes

Contents

require "bullet_train/outgoing_webhooks/version"
require "bullet_train/outgoing_webhooks/engine"

module BulletTrain
  module OutgoingWebhooks
    def self.default_for(klass, method, default_value)
      klass.respond_to?(method) ? klass.send(method) || default_value : default_value
    end

    mattr_accessor :parent_class, default: default_for(BulletTrain, :parent_class, "Team")
    mattr_accessor :base_class, default: default_for(BulletTrain, :base_class, "ApplicationRecord")

    def self.parent_association
      parent_class.underscore.to_sym
    end

    def self.parent_resource
      parent_class.underscore.pluralize.to_sym
    end

    def self.parent_class_specified?
      parent_class != "Team"
    end

    def self.current_parent_method
      "current_#{parent_association}"
    end

    def self.parent_association_id
      "#{parent_association}_id".to_sym
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bullet_train-outgoing_webhooks-1.2.4 lib/bullet_train/outgoing_webhooks.rb
bullet_train-outgoing_webhooks-1.2.3 lib/bullet_train/outgoing_webhooks.rb
bullet_train-outgoing_webhooks-1.2.2 lib/bullet_train/outgoing_webhooks.rb
bullet_train-outgoing_webhooks-1.2.1 lib/bullet_train/outgoing_webhooks.rb
bullet_train-outgoing_webhooks-1.2.0 lib/bullet_train/outgoing_webhooks.rb
bullet_train-outgoing_webhooks-1.1.0 lib/bullet_train/outgoing_webhooks.rb
bullet_train-outgoing_webhooks-1.0.5 lib/bullet_train/outgoing_webhooks.rb