module ActiveModel::Attributes

def attributes

# => {"name"=>"Francesco", "age"=>22}
person.attributes
person = Person.new(name: 'Francesco', age: 22)

end
attribute :age, :integer
attribute :name, :string

include ActiveModel::Attributes
class Person

Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
def attributes
  @attributes.to_hash
end