ticketevolution/ticketevolution-ruby — Issue #18: Allow response handler blocks to be passed in to request methods
Author: bluefocus
Created: 2012-02-26 16:33:56+00:00
State: open

This would allow for overriding the default response handling functionality:

https://github.com/ticketevolution/ticketevolution-ruby/blob/master/lib/ticket_evolution/modules/deleted.rb

module Deleted
def deleted(params = nil)
request(:GET, '/deleted', params, &method(:build_for_deleted))
end

def build_for_deleted(response)
TicketEvolution::Collection.build_from_response(response, self.class.name.demodulize.underscore, singular_class)
end
end

becomes something like:

module Deleted
def deleted(params = nil, &handler)
handler ||= &method(:build_for_deleted)
request(:GET, '/deleted', params, &handler)
end

def build_for_deleted(response)
TicketEvolution::Collection.build_from_response(response, self.class.name.demodulize.underscore, singular_class)
end
end