Sha256: 810b3a76d8b8e30925759d97039c88c1beffd1683e26fcf88db8dfdace4a2f99

Contents?: true

Size: 928 Bytes

Versions: 10

Compression:

Stored size: 928 Bytes

Contents

# frozen_string_literal: true
module Shipit
  class GithubHook < Record
    # TODO: app-migration, delete class
    belongs_to :stack, required: false # Required for fixtures

    before_destroy :teardown!

    delegate :github_repo_name, to: :stack

    def teardown!
      destroy_hook! if already_setup?
      true
    end

    def event=(event)
      super(event.to_s)
    end

    def already_setup?
      github_id?
    end

    def api
      Shipit.legacy_github_api
    end

    class Repo < GithubHook
      belongs_to :stack, required: true

      private

      def destroy_hook!
        api.remove_hook(github_repo_name, github_id)
      rescue Octokit::NotFound
      end
    end

    class Organization < GithubHook
      validates :organization, presence: true

      private

      def destroy_hook!
        api.remove_org_hook(organization, github_id)
      rescue Octokit::NotFound
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shipit-engine-0.39.0 app/models/shipit/github_hook.rb
shipit-engine-0.38.0 app/models/shipit/github_hook.rb
shipit-engine-0.37.0 app/models/shipit/github_hook.rb
shipit-engine-0.36.1 app/models/shipit/github_hook.rb
shipit-engine-0.36.0 app/models/shipit/github_hook.rb
shipit-engine-0.35.1 app/models/shipit/github_hook.rb
shipit-engine-0.35.0 app/models/shipit/github_hook.rb
shipit-engine-0.34.0 app/models/shipit/github_hook.rb
shipit-engine-0.33.0 app/models/shipit/github_hook.rb
shipit-engine-0.32.0 app/models/shipit/github_hook.rb