I’m starting to read through a new code base this week. In my latest plugin I’ve integrated formtastic with Redmine, so I decided to start reading through some of formtastic’s methods to better understand how it works. The Code To start using formtastic, you use the semantic_form_for method so this will be a prime spot …
Tag: code-reading
Daily Code Reading #25 – RestClient::AbstractResponse
Since yesterday I reviewed the RestClient::Response class, it’s time to read the parent class RestClient::AbstractResponse. There are a few interesting methods in AbstractResponse but the #return! method is a good one to review. The Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 …
Daily Code Reading #24 – RestClient::Response
Yesterday I looked at the Request side of RestClient so I’m reading through the RestClient::Response class today. RestClient::Request#execute returns this response object from it’s #process_result. 1 response = Response.new(Request.decode(res['content-encoding'], res.body), res, args)response = Response.new(Request.decode(res['content-encoding'], res.body), res, args) The Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 …
Daily Code Reading #23 – RestClient::Request#execute
After looking at the other RestClient::Resource methods from yesterday, I noticed that they are all almost identical to #get. So today I’m going to dig into the code one level down, RestClient::Request. The Code RestClient::Request#execute 1 2 3 4 5 6 7 module RestClient class Request def self.execute(args, &block) new(args).execute &block end end endmodule RestClient …
Daily Code Reading #22 – RestClient::Resource#get
From yesterday’s code reading, I found that the restclient command uses RestClient::Resource for most of the work. So I’m going to start with it’s methods, starting with it’s HTTP verbs, #get. The Code 1 2 3 4 5 6 7 8 9 10 11 module RestClient class Resource def get(additional_headers={}, &block) headers = (options[:headers] || …