Repository is archived
No commit activity in last 3 years
No release in over 3 years
# better-initialize A friendlier, dependency-free initialize method for ruby objects. ## Usage Gemfile: gem 'better-initialize', github: 'huned/better-initialize' Code: require 'better_initialize' class Pizza include BetterInitialize attr_accessor :size, :toppings end # Instantiate with attributes. Pizza.new(size: :large, toppings: %i[mushrooms peppers]) # Instantiate with attributes and a block. Pizza.new(size: :large) do |pizza| pizza.toppings = %w[mushrooms peppers] Oven.bake!(pizza) end ## Development Environment (OSX) brew install rbenv ruby-build git clone git@github.com:huned/better-initialize rbenv install -k `cat .ruby-version` bundle exec ruby test/run.rb
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

 Project Readme

better-initialize

A friendlier, dependency-free initialize method for ruby objects.

Usage

Gemfile:

gem 'better-initialize',
  github: 'huned/better-initialize'

Code:

require 'better_initialize'

class Pizza
  include BetterInitialize
  attr_accessor :size, :toppings
end

# Instantiate with attributes.
Pizza.new(size: :large, toppings: %i[mushrooms peppers])

# Instantiate with attributes and a block.
Pizza.new(size: :large) do |pizza|
  pizza.toppings = %w[mushrooms peppers]
  Oven.bake!(pizza)
end

Development Environment (OSX)

brew install rbenv ruby-build
git clone git@github.com:huned/better-initialize
rbenv install -k `cat .ruby-version`
bundle exec ruby test/run.rb