Skip to content

Commit

Permalink
Rename private method initialize_attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed May 19, 2012
1 parent 171ab37 commit 050378c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/toy/attributes.rb
Expand Up @@ -27,7 +27,7 @@ def attribute?(key)
end

def initialize(attrs={})
initialize_attributes_with_defaults
initialize_attributes
self.attributes = attrs
write_attribute :id, self.class.next_key(self) unless id?
end
Expand Down Expand Up @@ -98,7 +98,7 @@ def attribute?(key)
read_attribute(key).present?
end

def initialize_attributes_with_defaults
def initialize_attributes
@attributes ||= {}
self.class.defaulted_attributes.each do |attribute|
@attributes[attribute.name.to_s] = attribute.default
Expand Down
2 changes: 1 addition & 1 deletion lib/toy/persistence.rb
Expand Up @@ -43,7 +43,7 @@ def initialize(attrs={})

def initialize_from_database(attrs={})
@_new_record = false
initialize_attributes_with_defaults
initialize_attributes
send("attributes=", attrs, false)
self
end
Expand Down
2 changes: 1 addition & 1 deletion lib/toy/reloadable.rb
Expand Up @@ -4,7 +4,7 @@ def reload
if attrs = adapter.read(id)
attrs['id'] = id
instance_variables.each { |ivar| instance_variable_set(ivar, nil) }
initialize_attributes_with_defaults
initialize_attributes
send(:attributes=, attrs, new_record?)
self.class.lists.each_key { |name| send(name).reset }
self.class.references.each_key { |name| send("reset_#{name}") }
Expand Down

0 comments on commit 050378c

Please sign in to comment.