Sha256: 469c9000fa0dcce501d4f6f616dbb90afc7396f896686cc4d53034a1b56ff87b

Contents?: true

Size: 910 Bytes

Versions: 14

Compression:

Stored size: 910 Bytes

Contents

module Shipit
  class GithubHook < ActiveRecord::Base
    # 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

14 entries across 14 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 app/models/shipit/github_hook.rb
shipit-engine-0.30.0 app/models/shipit/github_hook.rb
shipit-engine-0.29.0 app/models/shipit/github_hook.rb
shipit-engine-0.28.1 app/models/shipit/github_hook.rb
shipit-engine-0.28.0 app/models/shipit/github_hook.rb
shipit-engine-0.27.1 app/models/shipit/github_hook.rb
shipit-engine-0.27.0 app/models/shipit/github_hook.rb
shipit-engine-0.26.0 app/models/shipit/github_hook.rb
shipit-engine-0.25.1 app/models/shipit/github_hook.rb
shipit-engine-0.25.0 app/models/shipit/github_hook.rb
shipit-engine-0.24.0 app/models/shipit/github_hook.rb
shipit-engine-0.23.1 app/models/shipit/github_hook.rb
shipit-engine-0.23.0 app/models/shipit/github_hook.rb
shipit-engine-0.22.0 app/models/shipit/github_hook.rb