# Class Event < ActiveRecord::Base

- app/models/event.rb

## Schema Information

Table name: events

    id          :integer          not null, primary key
    target_type :string(255)
    target_id   :integer
    title       :string(255)
    data        :text
    project_id  :integer
    created_at  :datetime         not null
    updated_at  :datetime         not null
    action      :integer
    author_id   :integer

Methods

A
  - action_name,
  - author
C
  - changed_issue?,
  - changed_merge_request?,
  - closed?
D
  - determine_action
I
  - issue,
  - issue?
J
  - joined?
L
  - left?
M
  - membership_changed?,
  - merge_request,
  - merge_request?,
  - merged?,
  - milestone?
N
  - new_issue?,
  - new_merge_request?,
  - note?
P
  - project_name,
  - proper?,
  - push?
R
  - reopened?
T
  - target_title

Included Modules

- NoteEvent
- PushEvent

Constants

Created | = | 1
Updated | = | 2
Closed | = | 3
Reopened | = | 4
Pushed | = | 5
Commented | = | 6
Merged | = | 7
Joined | = | 8
Left | = | 9

Class Public methods
determine_action(record) Link

Source: show

    # File app/models/event.rb, line 53
    def determine_action(record)
      if [Issue, MergeRequest].include? record.class
        Event::Created
      elsif record.kind_of? Note
        Event::Commented
      end
    end

Instance Public methods
action_name() Link

Source: show

    # File app/models/event.rb, line 160
    def action_name
      if closed?
        "closed"
      elsif merged?
        "merged"
      elsif joined?
        'joined'
      elsif left?
        'left'
      else
        "opened"
      end
    end

author() Link

Source: show

    # File app/models/event.rb, line 156
    def author
      @author ||= User.find(author_id)
    end

changed_issue?() Link

Source: show

    # File app/models/event.rb, line 131
    def changed_issue?
      target_type == "Issue" &&
        [Closed, Reopened].include?(action)
    end

changed_merge_request?() Link

Source: show

    # File app/models/event.rb, line 126
    def changed_merge_request?
      target_type == "MergeRequest" &&
        [Closed, Reopened].include?(action)
    end

closed?() Link

Source: show

    # File app/models/event.rb, line 92
    def closed?
      action == self.class::Closed
    end

issue() Link

Source: show

    # File app/models/event.rb, line 148
    def issue
      target if target_type == "Issue"
    end

issue?() Link

Source: show

    # File app/models/event.rb, line 108
    def issue?
      target_type == "Issue"
    end

joined?() Link

Source: show

    # File app/models/event.rb, line 136
    def joined?
      action == Joined
    end

left?() Link

Source: show

    # File app/models/event.rb, line 140
    def left?
      action == Left
    end

membership_changed?() Link

Source: show

    # File app/models/event.rb, line 144
    def membership_changed?
      joined? || left?
    end

merge_request() Link

Source: show

    # File app/models/event.rb, line 152
    def merge_request
      target if target_type == "MergeRequest"
    end

merge_request?() Link

Source: show

    # File app/models/event.rb, line 112
    def merge_request?
      target_type == "MergeRequest"
    end

merged?() Link

Source: show

    # File app/models/event.rb, line 88
    def merged?
      action == self.class::Merged
    end

milestone?() Link

Source: show

    # File app/models/event.rb, line 100
    def milestone?
      target_type == "Milestone"
    end

new_issue?() Link

Source: show

    # File app/models/event.rb, line 116
    def new_issue?
      target_type == "Issue" &&
        action == Created
    end

new_merge_request?() Link

Source: show

    # File app/models/event.rb, line 121
    def new_merge_request?
      target_type == "MergeRequest" &&
        action == Created
    end

note?() Link

Source: show

    # File app/models/event.rb, line 104
    def note?
      target_type == "Note"
    end

project_name() Link

Source: show

    # File app/models/event.rb, line 72
    def project_name
      if project
        project.name
      else
        "(deleted project)"
      end
    end

proper?() Link

Source: show

    # File app/models/event.rb, line 62
    def proper?
      if push?
        true
      elsif membership_changed?
        true
      else
        (issue? || merge_request? || note? || milestone?) && target
      end
    end

push?() Link

Source: show

    # File app/models/event.rb, line 84
    def push?
      action == self.class::Pushed && valid_push?
    end

reopened?() Link

Source: show

    # File app/models/event.rb, line 96
    def reopened?
      action == self.class::Reopened
    end

target_title() Link

Source: show

    # File app/models/event.rb, line 80
    def target_title
      target.try :title
    end