Sha256: 686652ae6ad89e73cacc6fca6215aa69d5648d8f9ba96d54e7e71ed505cd8e1a

Contents?: true

Size: 622 Bytes

Versions: 2

Compression:

Stored size: 622 Bytes

Contents

# option_initializer

Provides syntactic sugar for constructing objects with method chaining.

## Installation

```
gem install option_initializer
```

## Usage

```ruby
require 'option_initializer'

class Person
  include OptionInitializer
  option_initializer :id, :name, :age

  def initialize opts
    @options = opts
  end

  def say_hello
    puts "Hi, I'm #{@options[:name]}!"
  end
end

# Then
john = Person.name('John Doe').age(19).id(1000).new

# becomes equivalent to
john = Person.new :id => 1000, :name => 'John Doe', :age => 19

# Method call shortcut
Person.name('John Doe').age(19).id(1000).say_hello
```

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
option_initializer-1.0.1 README.md
option_initializer-1.0.0 README.md