konstructor 0.4.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +20 -11
- data/lib/konstructor/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b25aee9c2f472261bbcca0e6089870ac86288c7
|
4
|
+
data.tar.gz: 7189a66fc0ee859892a97a9534ad10ca02280af1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19e2dd031b428fba484ad91b2f187ccb73453ddca97448ebe3d3c68884f1f569474515103abc66fe8af3234a08fe972f897f5ff80ba9b7b8098202ae9f70092a
|
7
|
+
data.tar.gz: 76f25aa0a032a26ed7246c27e6cd51a9390f3b770d6540bb6b795f0d622c3e65fdb5a01e203d00d89a67835535a0e3a0e5a0ea85163894b6f182b73d0b97bcdd
|
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
[][gem]
|
2
2
|
[][travis]
|
3
3
|
[][coveralls]
|
4
|
+
[][codeclimate]
|
5
|
+
[][gemnasium]
|
4
6
|
|
5
7
|
[gem]: https://rubygems.org/gems/konstructor
|
6
8
|
[travis]: http://travis-ci.org/snovity/konstructor
|
7
9
|
[coveralls]: https://coveralls.io/github/snovity/konstructor
|
10
|
+
[gemnasium]: https://gemnasium.com/snovity/konstructor
|
11
|
+
[codeclimate]: https://codeclimate.com/github/snovity/konstructor
|
8
12
|
|
9
13
|
# Konstructor
|
10
14
|
|
@@ -116,7 +120,7 @@ and two additional ones.
|
|
116
120
|
```
|
117
121
|
|
118
122
|
If you decide to remove the default Ruby constructor for some reason,
|
119
|
-
you can
|
123
|
+
you can achieve the effect by marking it private with Ruby
|
120
124
|
method `private_class_method`:
|
121
125
|
|
122
126
|
```ruby
|
@@ -187,6 +191,9 @@ class SomeClass
|
|
187
191
|
@number = some_number
|
188
192
|
end
|
189
193
|
end
|
194
|
+
|
195
|
+
obj0 = SomeClass.create(3)
|
196
|
+
obj1 = SomeClass.create("three") # raises contract exception
|
190
197
|
```
|
191
198
|
|
192
199
|
If you stumble upon a metaprogramming gem that
|
@@ -195,19 +202,20 @@ conflicts with Konstructor, please
|
|
195
202
|
|
196
203
|
## Details
|
197
204
|
|
198
|
-
Ruby constructor is a pair consisting of public
|
199
|
-
|
200
|
-
|
205
|
+
The default Ruby constructor is a pair consisting of public
|
206
|
+
class method `new` and a private instance
|
207
|
+
method `initialize`. To create an additional one `konstructor`
|
208
|
+
marks given instance method as private and defines a
|
201
209
|
corresponding public class method with the same name.
|
202
210
|
|
203
211
|
#### Performance
|
204
212
|
|
205
|
-
|
206
|
-
|
207
|
-
|
213
|
+
Using `konstructor` declaration has no runtime perfomance penalty,
|
214
|
+
since all work is done during class definition and then it's just
|
215
|
+
standard Ruby instance creation.
|
208
216
|
|
209
|
-
|
210
|
-
|
217
|
+
Cost of `konstructor` declaration at initial load time is roughly the
|
218
|
+
same as declaring 3 properties with `attr_accessor`.
|
211
219
|
```ruby
|
212
220
|
attr_accessor :one, :two, :three
|
213
221
|
|
@@ -219,9 +227,10 @@ it's roughly the same as declaring 3 properties with `attr_accessor`.
|
|
219
227
|
See [Benchmarks page](https://github.com/snovity/konstructor/wiki/Benchmarks)
|
220
228
|
for details.
|
221
229
|
|
222
|
-
#### Dependencies
|
230
|
+
#### Dependencies and requirements
|
223
231
|
|
224
|
-
Konstructor doesn't depend on other gems.
|
232
|
+
Konstructor doesn't depend on other gems.
|
233
|
+
Requires Ruby `2.0.0` or higher.
|
225
234
|
|
226
235
|
#### Thread safety
|
227
236
|
|
data/lib/konstructor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konstructor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dima Lashkov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.4.8
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: Multiple constructors in Ruby.
|