ActiveModel::AttributeMethods::ClassMethods

module ActiveModel::AttributeMethods::ClassMethods

Public Instance Methods

alias_attribute(new_name, old_name) Show source

Allows you to make aliases for attributes.

class Person
  include ActiveModel::AttributeMethods

  attr_accessor :name
  attribute_method_suffix '_short?'
  define_attribute_methods :name

  alias_attribute :nickname, :name

  private

  def attribute_short?(attr)
    send(attr).length < 5
  end
end

person = Person.new
person.name = 'Bob'
pers