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

Setting a key using send should return the new value #557

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/mongo_mapper/plugins/keys.rb
Expand Up @@ -410,7 +410,6 @@ def internal_write_key(name, value, cast = true)
else
@_dynamic_attributes[key.name.to_sym] = as_typecast
end
@attributes = nil
end

def dynamic_key(name)
Expand Down
10 changes: 10 additions & 0 deletions spec/functional/keys_spec.rb
Expand Up @@ -24,6 +24,16 @@ def get_foo
instance.get_foo.should == instance.foo
end

it "should return the value when set using send with the writer method" do
doc = Doc do
key :foo, String
end

instance = doc.new(:foo => 'bar')
instance.send("foo=", 'baz').should == 'baz'
instance.foo.should == 'baz'
end

it "should not bomb if a key is written before Keys#initialize gets to get called" do
doc = Class.new do
include MongoMapper::Document
Expand Down