Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix read defaults after freeze #105

Merged
merged 6 commits into from
Jul 21, 2012

Conversation

mbj
Copy link
Collaborator

@mbj mbj commented Jul 19, 2012

No description provided.

Markus Schirp added 3 commits July 19, 2012 20:01
* A fix will be in next commit to allow easy testing.
* As defaults are lazy-set on first access, accessing a
  attribute with a default on a previously frozen object
  blows up without this patch.

* I choose not to call #get_attributes as this creates an wasted
  attribute hash.
* This solution should also work for jruby, rbx etc.
#
def freeze
# Call get_attribute on all attribute to ensure defaults are set prior to freezing
attribute_set.each do |attribute|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest moving this into a private method named something like load_defaults or something clear. You can then move the comment to the method's summary.

dkubb added a commit that referenced this pull request Jul 21, 2012
@dkubb dkubb merged commit 0aa0649 into solnic:master Jul 21, 2012
@dkubb
Copy link
Collaborator

dkubb commented Jul 21, 2012

@mbj this is fantastic, thanks, merged!

@mbj mbj mentioned this pull request Feb 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants