Module: Mongoid::Fields::LocalizedDefaults
- Defined in:
- lib/workarea/ext/freedom_patches/mongoid_localized_defaults.rb
Instance Method Summary collapse
Instance Method Details
#create_accessors(name, meth, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/workarea/ext/freedom_patches/mongoid_localized_defaults.rb', line 4 def create_accessors(name, meth, = {}) super if [:localize] field = fields[name] define_method meth do |*args| result = super(*args) return result unless result.nil? default_name = field.send(:default_name) return send(default_name) if respond_to?(default_name) field.default_val end end end |