README.md in konstructor-0.4.0 vs README.md in konstructor-0.4.1
- old
+ new
@@ -1,12 +1,12 @@
[![Gem Version](http://img.shields.io/gem/v/konstructor.svg)][gem]
-[![Build Status](http://img.shields.io/travis/snovity/konstructor.svg)][travis]
-[![Coverage Status](http://img.shields.io/coveralls/snovity/konstructor.svg)][coveralls]
+[![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]
[gem]: https://rubygems.org/gems/konstructor
[travis]: http://travis-ci.org/snovity/konstructor
-[coveralls]: https://coveralls.io/r/snovity/konstructor
+[coveralls]: https://coveralls.io/github/snovity/konstructor
# Konstructor
This is a small gem that gives you multiple
constructors in Ruby.
@@ -52,67 +52,80 @@
## Usage
In its simplest form `konstructor` declaration creates a
constructor from the next method.
- ```ruby
+```ruby
konstructor
def create
end
konstructor
def recreate
end
- ```
+```
When method names are given, it creates constructors from
those methods without affecting the next method.
- ```ruby
+```ruby
konstructor :create, :recreate
- def not_constructor
+ def not_a_constructor
end
def create
end
def recreate
end
- ```
+```
- Declaration with method names can be placed anywhere in
- class definition.
+Declaration with method names can be placed anywhere in
+class definition.
- ```ruby
+```ruby
def create
end
konstructor :create
konstructor
def recreate
end
- ```
+```
- In all above cases `SomeClass` will have the default constructor
- and two additional ones.
+Several declarations may be used,
+all declarations add up without overwriting each other.
+```ruby
+ def create
+ end
+
+ konstructor :recreate
+ konstructor :create
+
+ def recreate
+ end
+```
- ```ruby
+In all above cases `SomeClass` will have the default constructor
+and two additional ones.
+
+```ruby
obj0 = SomeClass.new
obj1 = SomeClass.create
obj2 = SomeClass.recreate
- ```
+```
- If you decide to remove the default Ruby constructor for some reason,
- you can effectively do it by marking it as private using Ruby
- method `private_class_method`:
+If you decide to remove the default Ruby constructor for some reason,
+you can effectively do it by marking it as private using Ruby
+method `private_class_method`:
- ```ruby
+```ruby
class SomeClass
private_class_method :new
end
- ```
+```
#### Same as default constructor
Additional constructors work exactly the same way as the default one.
@@ -196,16 +209,18 @@
As for the cost of declaring a constructor at initial load time,
it's roughly the same as declaring 3 properties with `attr_accessor`.
```ruby
attr_accessor :one, :two, :three
- # following declaration take the same time as above declaration
+ # following declaration takes the same time as above declaration
konstructor
def create
end
```
See [Benchmarks page](https://github.com/snovity/konstructor/wiki/Benchmarks)
for details.
+
+#### Dependencies
Konstructor doesn't depend on other gems.
#### Thread safety