lib/ldp/client/methods.rb in ldp-1.0.3 vs lib/ldp/client/methods.rb in ldp-1.1.0

- old
+ new

@@ -8,14 +8,15 @@ if http_client.length == 1 and http_client.first.is_a? Faraday::Connection @http = http_client.first else @http = Faraday.new *http_client end + yield @http if block_given? end def head url - ActiveSupport::Notifications.instrument("http.ldp", + Ldp.instrument("http.ldp", url: url, name: "HEAD", ldp_client: object_id) do resp = http.head do |req| req.url munge_to_relative_url(url) yield req if block_given? @@ -27,11 +28,11 @@ end end # Get a LDP Resource by URI def get url, options = {} - ActiveSupport::Notifications.instrument("http.ldp", + Ldp.instrument("http.ldp", url: url, name: "GET", ldp_client: object_id) do resp = http.get do |req| req.url munge_to_relative_url(url) prefer_headers = ::Ldp::PreferHeaders.new @@ -55,11 +56,11 @@ end end # Delete a LDP Resource by URI def delete url - ActiveSupport::Notifications.instrument("http.ldp", + Ldp.instrument("http.ldp", url: url, name: "DELETE", ldp_client: object_id) do resp = http.delete do |req| req.url munge_to_relative_url(url) yield req if block_given? end @@ -68,11 +69,11 @@ end end # Post TTL to an LDP Resource def post url, body = nil, headers = {} - ActiveSupport::Notifications.instrument("http.ldp", + Ldp.instrument("http.ldp", url: url, name: "POST", ldp_client: object_id) do resp = http.post do |req| req.url munge_to_relative_url(url) req.headers.merge!(default_headers).merge!(headers) req.body = body @@ -82,11 +83,11 @@ end end # Update an LDP resource with TTL by URI def put url, body, headers = {} - ActiveSupport::Notifications.instrument("http.ldp", + Ldp.instrument("http.ldp", url: url, name: "PUT", ldp_client: object_id) do resp = http.put do |req| req.url munge_to_relative_url(url) req.headers.merge!(default_headers).merge!(headers) req.body = body @@ -96,10 +97,10 @@ end end # Update an LDP resource with TTL by URI def patch url, body, headers = {} - ActiveSupport::Notifications.instrument("http.ldp", + Ldp.instrument("http.ldp", url: url, name: "PATCH", ldp_client: object_id) do resp = http.patch do |req| req.url munge_to_relative_url(url) req.headers.merge!(default_patch_headers).merge!(headers) req.body = body