lib/acfs/operation.rb in acfs-0.30.0.1.b261 vs lib/acfs/operation.rb in acfs-0.30.0.1.b262

- old
+ new

@@ -4,11 +4,11 @@ # # Describes a CRUD operation. Handle request creation and response # processing as well as error handling and stubbing. # class Operation - attr_reader :action, :params, :resource, :data, :callback, :location + attr_reader :action, :params, :resource, :data, :callback, :location, :url delegate :service, to: :resource delegate :call, to: :callback def initialize(resource, action, opts = {}, &block) @resource = resource @@ -18,10 +18,11 @@ # later in-place changes by modifying passed hash @params = (opts[:params] || {}).dup @data = (opts[:data] || {}).dup @location = resource.location(action: @action).extract_from(@params, @data) + @url = location.str @callback = block end def single? @@ -44,10 +45,10 @@ def method { read: :get, list: :get, update: :put, create: :post, delete: :delete }[action] end def request - request = ::Acfs::Request.new location.str, method: method, params: params, data: data + request = ::Acfs::Request.new url, method: method, params: params, data: data request.on_complete do |response| handle_failure response unless response.success? callback.call response.data end request