Skip to content

Commit

Permalink
Allow explicit nil for #initialize/#attributes=
Browse files Browse the repository at this point in the history
  • Loading branch information
leshill committed Jun 4, 2011
1 parent 33a95cb commit 9bde963
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/informal/model_no_init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def self.included(klass)
end

def attributes=(attrs)
return unless attrs.is_a? Hash
attrs.each_pair { |name, value| self.send("#{name}=", value) }
end

Expand Down
5 changes: 5 additions & 0 deletions test/model_test_cases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ def test_new
assert_nil @model.z
end

def test_new_with_nil
@model = self.poro_class.new(nil)
assert_not_nil @model
end

def test_persisted
assert !@model.persisted?
end
Expand Down

0 comments on commit 9bde963

Please sign in to comment.