Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Remove simple links from data when parsed #6

Merged
merged 1 commit into from

1 participant

@pengwynn
Owner

*_url links are removed from Resource#data when parsed to be consistent with the HAL parser behavior.

@pengwynn pengwynn merged commit e92351e into master
@pengwynn pengwynn deleted the remove-simple-rels-from-data branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2013
  1. @pengwynn
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +1 −1  lib/sawyer/link_parsers/simple.rb
  2. +3 −0  test/resource_test.rb
View
2  lib/sawyer/link_parsers/simple.rb
@@ -17,7 +17,7 @@ def parse(data)
inline_links = data.keys.select {|k| k.to_s[LINK_REGEX] }
inline_links.each do |key|
rel_name = key.to_s == 'url' ? 'self' : key.to_s.gsub(LINK_REGEX, '')
- links[rel_name.to_sym] = data[key]
+ links[rel_name.to_sym] = data.delete(key)
end
return data, links
View
3  test/resource_test.rb
@@ -131,9 +131,12 @@ def test_simple_rel_parsing
assert_equal '/', res.rels[:self].href
assert_kind_of Resource, res.user
+ assert !res.fields.include?(:url)
assert_equal 1, res.user.id
assert_equal '/users/1', res.user.rels[:self].href
+ assert !res.user.fields.include?(:url)
assert_equal '/users/1/followers', res.user.rels[:followers].href
+ assert !res.user.fields.include?(:followers_url)
end
end
end
Something went wrong with that request. Please try again.