README.md in option_initializer-1.2.0 vs README.md in option_initializer-1.3.0
- old
+ new
@@ -13,15 +13,13 @@
```ruby
require 'option_initializer'
class Person
include OptionInitializer
- option_initializer :id, :name, :age, :greetings
+ option_initializer :id, :name, :greetings => :block, :birthday => 1..3
option_validator do |k, v|
case k
- when :age
- raise ArgumentError, "invalid age" if v < 0
when :name
raise ArgumentError, "invalid name" if v.empty?
end
end
@@ -36,19 +34,19 @@
end
# Then
john = Person.
name('John Doe').
- age(19).
+ birthday(1990, 1, 1).
greetings { |name| "Hi, I'm #{name}!" }.
id(1000).
new
# becomes equivalent to
john = Person.new(
:id => 1000,
:name => 'John Doe',
- :age => 19,
+ :birthday => [1990, 1, 1],
:greetings => proc { |name| "Hi, I'm #{name}!" }
)
# Method call shortcut
class Person