• Home
  • About
    • Bio
    • CV
  • Music
    • Shows
    • Works
  • Research
    • Works
  • Programming
    • Projects
  • Blog
    • Watson
    • Viget
  • Contact
    • Message
    • Subscribe
    • Availability

More Understanding

02 Aug 2016

Reading time ~1 minute

What I Did

  1. I spent more time understanding Rails/CK integration and continued cranking out integration tests for “These Numbers Matter”.

    What I Learned

  2. attr_accessor :name really just does the following:
    def name
      @name
    end
    def name=(str)
      @name = str
    end
    

    attr_accessor is 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.

  3. 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 send method 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.
  4. 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 nil? and empty?
    • present? is the negation of blank.
  5. It’s important to remember that Rspec is simply a DSL written in Ruby targeted at testing.
  6. A UID (unique identifier) is a numeric or alphanumeric string that is associated with a single entity within a given system.


Share Tweet +1