Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Standup 1/5/2012 – The Death of SOAP


Soap4R and Ruby 1.9.2

“Soap4R and Ruby 1.9.2 don’t work, what’s the best alternative?”

Several people recommended the Savon gem. It was strongly suggested to not try and replicate any of the Soap protocol because it is pretty painful to implement.


Constants versus Immutable Objects

Someone apparently had confusion around what it means to be constant in Ruby, and what it means to be immutable.

A constant prevents modifications to references to variables.

warning: already initialized constant SOME_CONST

Immutability means that the variables themselves cannot be modified.

an_array = [1,2,3]
an_array[3] = 4
RuntimeError: can't modify frozen array

You should note, though, that freezing an object only makes the variables that object contains immutable. For instance,

an_array = [1,2,3,{}]
an_array[3]["foo"] = "bar"

will not throw any errors or warnings.

  1. I usually freeze each of my objects when I’m making constants:

    ACCEPTED_METHODS = %w( GET POST PUT DELETE ).map(&:freeze).freeze

    This freezes each of the words, and the whole collection as well. The last example could be similarly frozen:

    an_array = [1,2,3,{}].map(&:freeze).freeze
    an_array[3][“foo”] = “bar”
    RuntimeError: can’t modify frozen hash

    But of course, if the values or keys aren’t frozen, the same issue applies.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *