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

parent fe9a372c
......@@ -6,7 +6,7 @@ module Bitbucket
end
def note
raw.dig('content', 'raw')
raw.fetch('content', {}).fetch('raw', nil)
end
def created_at
......
......@@ -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
......
......@@ -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
......
......@@ -18,7 +18,7 @@ module Bitbucket
end
def parent_id
raw.dig('parent', 'id')
raw.fetch('parent', {}).fetch('id', nil)
end
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