Skip to content
Browse files

Disallow mutation of ValueObjects via #attributes=

* Increases consistency as mutations on value objects should be
  created via #with(mutations).
  • Loading branch information...
1 parent 0aa0649 commit d97bfa41e01e245cfb9af80e4f5ad9e132aa64c4 Markus Schirp committed Jul 27, 2012
Showing with 2 additions and 1 deletion.
  1. +1 −0 lib/virtus/value_object.rb
  2. +1 −1 spec/integration/virtus/value_object_spec.rb
View
1 lib/virtus/value_object.rb
@@ -35,6 +35,7 @@ def self.included(base)
include ::Virtus
include InstanceMethods
extend ClassMethods
+ private :attributes=
end
end
View
2 spec/integration/virtus/value_object_spec.rb
@@ -40,7 +40,7 @@ def self.name
it 'writer methods are set to private' do
private_methods = class_under_test.private_instance_methods
private_methods.map! { |m| m.to_s }
- private_methods.should include('latitude=', 'longitude=')
+ private_methods.should include('latitude=', 'longitude=', 'attributes=')
end
it 'attempts to call attribute writer methods raises NameError' do

0 comments on commit d97bfa4

Please sign in to comment.
Something went wrong with that request. Please try again.