02 Aug 2016
Reading time ~1 minute
What I Did
- I spent more time understanding Rails/CK integration and continued cranking out integration tests for “These Numbers Matter”.
What I Learned
attr_accessor :namereally just does the following:
def name @name end def name=(str) @name = str end
attr_accessoris accessible throughout an object’s life cycle. When an object is saved using any of ActiveRecord’s methods (save, update, etc.) all attributes of your Model other than attr_accessor are saved in the database.
- Every time you call a method on an object, all you’re really doing is “sending” that object a “message” where the message is the name of the method you called. In this way, the
sendmethod allows you to send a message (or call a method) on an object when you don’t know the name of the method until runtime. This is most applicable to instances in which meta programming is involved.
- Here’s a review on presence calls in RoR:
nil?can be used on any object
empty?can only be used on arrays, Hashes, String, and the like (it returns true if the object has no value at all)
blank?is a Rails implementation allowing for the combination of both
present?is the negation of blank.
- It’s important to remember that Rspec is simply a DSL written in Ruby targeted at testing.
- A UID (unique identifier) is a numeric or alphanumeric string that is associated with a single entity within a given system.