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
def note
raw.dig('content', 'raw')
raw.fetch('content', {}).fetch('raw', nil)
end
def created_at

View file

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

View file

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

View file

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