Module: Mongoid::Attributes::ClassMethods
- Defined in:
- lib/mongoid/attributes.rb
Instance Method Summary collapse
-
#alias_attribute(name, original) ⇒ Object
Alias the provided name to the original field.
Instance Method Details
#alias_attribute(name, original) ⇒ Object
Alias the provided name to the original field. This will provide an aliased getter, setter, existance check, and all dirty attribute methods.
369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/mongoid/attributes.rb', line 369 def alias_attribute(name, original) class_eval <<-RUBY alias #{name} #{original} alias #{name}= #{original}= alias #{name}? #{original}? alias #{name}_change #{original}_change alias #{name}_changed? #{original}_changed? alias reset_#{name}! reset_#{original}! alias #{name}_was #{original}_was alias #{name}_will_change! #{original}_will_change! alias #{name}_before_type_cast #{original}_before_type_cast RUBY end |