gitlab-org--gitlab-foss/lib/bitbucket/representation/pull_request.rb
gfyoung d598e4fd93 Enable more frozen string in lib/**/*.rb
Enables frozen for the following:

* lib/*.rb
* lib/banzai/**/*.rb
* lib/bitbucket/**/*.rb
* lib/constraints/**/*.rb
* lib/container_registry/**/*.rb
* lib/declarative_policy/**/*.rb

Partially addresses #47424.
2018-10-06 17:02:50 -07:00

67 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module Bitbucket
module Representation
class PullRequest < Representation::Base
def author
raw.fetch('author', {}).fetch('username', nil)
end
def description
raw['description']
end
def iid
raw['id']
end
def state
if raw['state'] == 'MERGED'
'merged'
elsif raw['state'] == 'DECLINED'
'closed'
else
'opened'
end
end
def created_at
raw['created_on']
end
def updated_at
raw['updated_on']
end
def title
raw['title']
end
def source_branch_name
source_branch.fetch('branch', {}).fetch('name', nil)
end
def source_branch_sha
source_branch.fetch('commit', {}).fetch('hash', nil)
end
def target_branch_name
target_branch.fetch('branch', {}).fetch('name', nil)
end
def target_branch_sha
target_branch.fetch('commit', {}).fetch('hash', nil)
end
private
def source_branch
raw['source']
end
def target_branch
raw['destination']
end
end
end
end