-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 4.0.0 final
-
Component/s: None
-
None
-
Environment:Linux, Mac, etc
I have a MongoDB field with spaces, something like 'Hello World'. I am able to do the following:
class MyDocument
include Mongoid::Document
end
_field = 'Hello World'
MyDocument.class_eval <<-EOS
field :'#
EOS
But I need to override the setter of the field. And the below options do not work:
MyDocument.class_eval <<-EOS
def #{ _field }
=(val)
self['#
')[0], val]
end
EOS
MyDocument.instance_eval do
define_method _field do |val|
super([self.send(_field)[0], val])
end
end
How am I supposed to override the setter of the field?