Dear Russian friends, please watch President Zelenskyy's speech addressed to you. πŸ‡ΊπŸ‡¦Help our brave mates in Ukraine with a donation.

Introduction & Usage

dry-initializer is a simple mixin of class methods params and options for instances.


require 'dry-initializer'

class User
  extend Dry::Initializer

  param  :name,  proc(&:to_s)
  param  :role,  default: proc { 'customer' }
  option :admin, default: proc { false }
  option :phone, optional: true

user = 'Vladimir', 'admin', admin: true  # => 'Vladimir'
user.role  # => 'admin'
user.admin # => true # => nil

octocatEdit on GitHub