Permalink
Browse files

Better namespace for link parsing

  • Loading branch information...
1 parent 0001176 commit 2ef9b36eedc0ff9229b32f9b27a2c789b329a589 @pengwynn pengwynn committed Mar 14, 2013
Showing with 17 additions and 2 deletions.
  1. +1 −1 lib/sawyer.rb
  2. +1 −1 lib/sawyer/agent.rb
  3. +15 −0 lib/sawyer/link_parsers/hal.rb
View
@@ -12,5 +12,5 @@ class Error < StandardError; end
response
serializer
agent
- hal_rels_parser
+ link_parsers/hal
).each { |f| require File.expand_path("../sawyer/#{f}", __FILE__) }
View
@@ -38,7 +38,7 @@ def initialize(endpoint, options = nil)
@endpoint = endpoint
@conn = (options && options[:faraday]) || Faraday.new
@serializer = (options && options[:serializer]) || self.class.serializer
- @links_parser = (options && options[:links_parser]) || HalLinksParser.new
+ @links_parser = (options && options[:links_parser]) || Sawyer::LinkParsers::Hal.new
@allow_undefined_methods = (options && options[:allow_undefined_methods])
@conn.url_prefix = @endpoint
yield @conn if block_given?
@@ -0,0 +1,15 @@
+module Sawyer
+ module LinkParsers
+
+ class Hal
+
+ def parse(data)
+ links = data.delete(:_links)
+
+ return data, links
+ end
+
+ end
+
+ end
+end

0 comments on commit 2ef9b36

Please sign in to comment.