module Mongoid::Changeable::ClassMethods
Private Instance Methods
Creates the dirty change accessor.
@example Create the accessor.
Model.create_dirty_change_accessor("name", "alias")
@param [ String ] name The attribute name. @param [ String ] meth The name of the accessor.
@since 3.0.0
# File lib/mongoid/changeable.rb, line 285 def create_dirty_change_accessor(name, meth) generated_methods.module_eval do re_define_method("#{meth}_change") do attribute_change(name) end end end
Creates the dirty change check.
@example Create the check.
Model.create_dirty_change_check("name", "alias")
@param [ String ] name The attribute name. @param [ String ] meth The name of the accessor.
@since 3.0.0
# File lib/mongoid/changeable.rb, line 302 def create_dirty_change_check(name, meth) generated_methods.module_eval do re_define_method("#{meth}_changed?") do attribute_changed?(name) end end end
Creates the dirty change flag.
@example Create the flag.
Model.create_dirty_change_flag("name", "alias")
@param [ String ] name The attribute name. @param [ String ] meth The name of the accessor.
@since 3.0.0
# File lib/mongoid/changeable.rb, line 353 def create_dirty_change_flag(name, meth) generated_methods.module_eval do re_define_method("#{meth}_will_change!") do attribute_will_change!(name) end end end
Creates the dirty default change check.
@example Create the check.
Model.create_dirty_default_change_check("name", "alias")
@param [ String ] name The attribute name. @param [ String ] meth The name of the accessor.
@since 3.0.0
# File lib/mongoid/changeable.rb, line 319 def create_dirty_default_change_check(name, meth) generated_methods.module_eval do re_define_method("#{meth}_changed_from_default?") do attribute_changed_from_default?(name) end end end
Generate all the dirty methods needed for the attribute.
@example Generate the dirty methods.
Model.create_dirty_methods("name", "name")
@param [ String ] name The name of the field. @param [ String ] name The name of the accessor.
@return [ Module ] The fields module.
@since 2.4.0
# File lib/mongoid/changeable.rb, line 267 def create_dirty_methods(name, meth) create_dirty_change_accessor(name, meth) create_dirty_change_check(name, meth) create_dirty_change_flag(name, meth) create_dirty_default_change_check(name, meth) create_dirty_previous_value_accessor(name, meth) create_dirty_reset(name, meth) end
Creates the dirty change previous value accessor.
@example Create the accessor.
Model.create_dirty_previous_value_accessor("name", "alias")
@param [ String ] name The attribute name. @param [ String ] meth The name of the accessor.
@since 3.0.0
# File lib/mongoid/changeable.rb, line 336 def create_dirty_previous_value_accessor(name, meth) generated_methods.module_eval do re_define_method("#{meth}_was") do attribute_was(name) end end end
Creates the dirty change reset.
@example Create the reset.
Model.create_dirty_reset("name", "alias")
@param [ String ] name The attribute name. @param [ String ] meth The name of the accessor.
@since 3.0.0
# File lib/mongoid/changeable.rb, line 370 def create_dirty_reset(name, meth) generated_methods.module_eval do re_define_method("reset_#{meth}!") do reset_attribute!(name) end end end