Build immutable classes #118

Closed
wants to merge 2 commits into
from

Projects

None yet

1 participant

@jamesottaway

Immutable classes are my friend, but machinist doesn't seem to like them. This patch fixes that.

The Lathe class has traditionally called the #{key}= method on the object in question to set a given value, but my immutable friends don't have that method.

Because attr_reader uses instance variables under the hood, machinist can set the instance variable in question to the given value and all will be happy.

I had to use a begin block in Lathe because the OpenStruct instances used by other specs in machinable_spec.rb doesn't support #respond_to?. If this was changed the patch could be refactored to use if @object.respond_to?("#{key}=").

James Ottaway added some commits Aug 1, 2012
James Ottaway Immutable classes don't have writer methods so violence is required t…
…o set the value of the instance variable matching the given key
6bb6c40
James Ottaway Share the immutable love in the README 9004b6c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment