Avoid use of Hash#dig to keep compatibility with Ruby 2.1

This commit is contained in:
Douglas Barbosa Alexandre 2016-12-16 19:51:40 -02:00
parent fe9a372c0b
commit a3be4aeb7a
4 changed files with 10 additions and 10 deletions

View file

@ -6,7 +6,7 @@ module Bitbucket
end end
def note def note
raw.dig('content', 'raw') raw.fetch('content', {}).fetch('raw', nil)
end end
def created_at def created_at

View file

@ -12,11 +12,11 @@ module Bitbucket
end end
def author def author
raw.dig('reporter', 'username') raw.fetch('reporter', {}).fetch('username', nil)
end end
def description def description
raw.dig('content', 'raw') raw.fetch('content', {}).fetch('raw', nil)
end end
def state def state
@ -28,7 +28,7 @@ module Bitbucket
end end
def milestone def milestone
raw.dig('milestone', 'name') raw['milestone']['name'] if raw['milestone'].present?
end end
def created_at def created_at

View file

@ -2,7 +2,7 @@ module Bitbucket
module Representation module Representation
class PullRequest < Representation::Base class PullRequest < Representation::Base
def author def author
raw.dig('author', 'username') raw.fetch('author', {}).fetch('username', nil)
end end
def description def description
@ -36,19 +36,19 @@ module Bitbucket
end end
def source_branch_name def source_branch_name
source_branch.dig('branch', 'name') source_branch.fetch('branch', {}).fetch('name', nil)
end end
def source_branch_sha def source_branch_sha
source_branch.dig('commit', 'hash') source_branch.fetch('commit', {}).fetch('hash', nil)
end end
def target_branch_name def target_branch_name
target_branch.dig('branch', 'name') target_branch.fetch('branch', {}).fetch('name', nil)
end end
def target_branch_sha def target_branch_sha
target_branch.dig('commit', 'hash') target_branch.fetch('commit', {}).fetch('hash', nil)
end end
private private

View file

@ -18,7 +18,7 @@ module Bitbucket
end end
def parent_id def parent_id
raw.dig('parent', 'id') raw.fetch('parent', {}).fetch('id', nil)
end end
def inline? def inline?