README.md in konstructor-1.0.0 vs README.md in konstructor-1.0.1

- old
+ new

@@ -1,6 +1,6 @@ -[![Gem Version](http://img.shields.io/gem/v/konstructor.svg)][gem] +[![Gem Version](https://badge.fury.io/rb/konstructor.svg)][gem] [![Build Status](https://travis-ci.org/snovity/konstructor.svg?branch=master)][travis] [![Coverage Status](https://coveralls.io/repos/github/snovity/konstructor/badge.svg?branch=master)][coveralls] [![Code Climate](https://codeclimate.com/github/snovity/konstructor/badges/gpa.svg)][codeclimate] [![Dependency Status](https://gemnasium.com/badges/github.com/snovity/konstructor.svg)][gemnasium] @@ -172,19 +172,43 @@ There are certain limitations to what can be declared as `konstructor`, see [Limitations page](https://github.com/snovity/konstructor/wiki/Limitations) for details. +#### Reusing default constructor + +Sometimes you don't want to completely replace the default constructor, +instead you just want to add additional processing before/after it. +```ruby +class Person + def initialize(name) + @name = name + @word_count = name.split(' ').size + end + + konstructor + def from_two_names(first_name, second_name) + initialize(first_name + ' ' + second_name) + @name_count = 2 + end + + attr_reader :name, :word_count, :name_count +end + +Person.new('John Doe') +Person.from_two_names('John', 'Doe') +``` + #### Using with other gems Konstructor doesn't affect other gems depending on metaprogramming, such as [rake](https://github.com/ruby/rake), [thor](https://github.com/erikhuda/thor), [contracts](https://github.com/egonSchiele/contracts.ruby), etc. -For instnace, this is how Konstructor works with contracts: +For instnace, this is how Konstructor works with Contracts: ```ruby class SomeClass konstructor Contract Num => SomeClass def create(some_number) @@ -228,10 +252,10 @@ for details. #### Dependencies and requirements Konstructor doesn't depend on other gems. -Requires Ruby `2.0.0` or higher. +Requires Ruby `1.9.3` or higher. #### Thread safety Konstructor is thread safe.