Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlyobvious committed Oct 20, 2023
1 parent 05bdc86 commit 31a21a2
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions aggregate_root/project_management/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,49 @@ def initialize(id)
end

def open
invalid_transition unless initial?
fail unless initial?
apply(IssueOpened.new(data: { issue_id: @id }))
end

def resolve
invalid_transition unless open? || reopened? || in_progress?
fail unless open? || reopened? || in_progress?
apply(IssueResolved.new(data: { issue_id: @id }))
end

def close
invalid_transition unless open? || in_progress? || reopened? || resolved?
fail unless open? || in_progress? || reopened? || resolved?
apply(IssueClosed.new(data: { issue_id: @id }))
end

def reopen
invalid_transition unless closed? || resolved?
fail unless closed? || resolved?
apply(IssueReopened.new(data: { issue_id: @id }))
end

def start
invalid_transition unless open? || reopened?
fail unless open? || reopened?
apply(IssueProgressStarted.new(data: { issue_id: @id }))
end

def stop
invalid_transition unless in_progress?
fail unless in_progress?
apply(IssueProgressStopped.new(data: { issue_id: @id }))
end

private

def invalid_transition = raise InvalidTransition
def fail = raise InvalidTransition
def initial? = @status.nil?
def open? = @status == :open
def closed? = @status == :closed
def in_progress? = @status == :in_progress
def reopened? = @status == :reopened
def resolved? = @status == :resolved

on(IssueOpened) { |event| @status = :open }
on(IssueResolved) { |event| @status = :resolved }
on(IssueClosed) { |event| @status = :closed }
on(IssueReopened) { |event| @status = :reopened }
on(IssueOpened) { |event| @status = :open }
on(IssueResolved) { |event| @status = :resolved }
on(IssueClosed) { |event| @status = :closed }
on(IssueReopened) { |event| @status = :reopened }
on(IssueProgressStarted) { |event| @status = :in_progress }
on(IssueProgressStopped) { |event| @status = :open }
end
Expand Down

0 comments on commit 31a21a2

Please sign in to comment.