Module: Mongoid::Autofields
- Defined in:
- lib/mongoid/autofields.rb
Overview
sloppily define undefined fields to make getting up and running with mongoid even easier.
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/mongoid/autofields.rb', line 4 def method_missing(m, *a) return super unless m =~ /=/ return super unless a.size == 1 meth = m.to_s.gsub('=', '') type = a.first.class self.class.field meth.to_sym, type: type self.send m.to_sym, *a end |