April 8, 2015 by Daniel P. Clark

ActiveRecord vs Me… Round 1 – FIGHT!

I’ve done a fair bit of work in creating a library that integrates with ActiveRecord Objects.  I also have a pretty good grasp on mixins/inheritance.  Yet I still run into situations where trying include, extend, and techniques for monkey patching just don’t work out. I was trying to implement a method like first_or_create on the…

Continue Reading »

March 9, 2015 by Daniel P. Clark

Ruby: Actionable Meta

The more you program the more likely you will need to change a string to the object the string represents. For example you may have a string with a mystery class name in it the you need to call methods on. Lets go a step further, lets say the method you need to call on…

Continue Reading »

March 3, 2015 by Daniel P. Clark

Ruby: The Case for Case

It’s nice to have case and when available in Ruby.  But I don’t see it used too often.  I myself don’t use it much because I’m more accustomed to just using if and else.  So let’s get into case switching. person = “employee” case person when “boss” puts “Yes sir!” when “employee” puts “Sure I’ll…

Continue Reading »

February 27, 2015 by Daniel P. Clark

Value Assignment and Deferment with Lambdas/Procs

When assigning a variable with a raw value the outcome is as you would expect. greeting = “hello” # => “hello” puts greeting # hello Now while learning about assigning methods to variables I used to wonder if I was assigning the result value from the method, or simply pointing to the method to be…

Continue Reading »

January 1, 2015 by Daniel P. Clark

When to use Ampersand and/or Colon with Proc, Map, and Inject

So with Ruby permitting Procs called on Objects I’ve found sometimes a Colon Method will work, and sometimes you need a Ampersand Colon Method.  For example, when I map &:upcase on a list of strings it works. [“a”,”b”,”c”].map(&:upcase) # = > [“A”, “B”, “C”] But if I try without the Ampersand I get: [“a”,”b”,”c”].map(:upcase) #…

Continue Reading »