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

parent fe9a372c
...@@ -6,7 +6,7 @@ module Bitbucket ...@@ -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
......
...@@ -12,11 +12,11 @@ module Bitbucket ...@@ -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 ...@@ -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
......
...@@ -2,7 +2,7 @@ module Bitbucket ...@@ -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 ...@@ -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
......
...@@ -18,7 +18,7 @@ module Bitbucket ...@@ -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?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment