DmitryTsepelev
Saint P Ruby Meetup Winter’22 😷
Цель: добавить и методы экземпляра и методы класса
54
class User
include CoolRecord
attr_accessor :id, :email, :name
def initialize(id: nil, email: nil, name: nil)
@id = id
@email = email
@name = name
end
end
user = User.new(email: '
[email protected]', name: 'John')
user.save
puts User.where(name: 'John').inspect #
= >
[#]
puts User.f
i
nd_by(name: 'John').inspect #
= >
#
puts User.where(name: 'Jane').inspect #
= >
[]
* https://gist.github.com/DmitryTsepelev/ab1797e7d00b484973615ba1782e0e36#
fi
le-07_instance_and_class_methods-rb