I find that i'm writing lots of initialize code that basically sets attrs to parameters... similar to this:
class SiteClient
attr_reader :login, :password, :domain
def initialize(login, password, site='somedefaultsite.com')
@login = login
@password = password
@domain = domain
end
end
Is there a more Ruby way of doing this? I feel like I'm writing that same boilerplate setup code over and over these days.
Thanks
Aucun commentaire:
Enregistrer un commentaire