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 296 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 313 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 364 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 330 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 ] meth The name of the accessor.
@return [ Module ] The fields module.
@since 2.4.0
# File lib/mongoid/changeable.rb, line 275 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) create_dirty_reset_to_default(name, meth) create_dirty_previously_changed?(name, meth) create_dirty_previous_change(name, meth) end
Creates the dirty change accessor.
@example Create the dirty change accessor.
Model.create_dirty_previous_change("name", "alias")
@param [ String ] name The attribute name. @param [ String ] meth The name of the accessor.
@since 6.0.0
# File lib/mongoid/changeable.rb, line 432 def create_dirty_previous_change(name, meth) generated_methods.module_eval do re_define_method("#{meth}_previous_change") do previous_changes[name] end end 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 347 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 check.
@example Create the dirty change check.
Model.create_dirty_previously_changed?("name", "alias")
@param [ String ] name The attribute name. @param [ String ] meth The name of the accessor.
@since 6.0.0
# File lib/mongoid/changeable.rb, line 415 def create_dirty_previously_changed?(name, meth) generated_methods.module_eval do re_define_method("#{meth}_previously_changed?") do previous_changes.keys.include?(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 381 def create_dirty_reset(name, meth) generated_methods.module_eval do re_define_method("reset_#{meth}!") do reset_attribute!(name) end end end
Creates the dirty change reset to default.
@example Create the reset.
Model.create_dirty_reset_to_default("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 398 def create_dirty_reset_to_default(name, meth) generated_methods.module_eval do re_define_method("reset_#{meth}_to_default!") do reset_attribute_to_default!(name) end end end