yieldable 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -21
  3. data/lib/yieldable/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3ec314bc5b85c0ce2c8a51066d428e69535eafe78a86b94e19bfc580b6140c5
4
- data.tar.gz: 3b72b7259dd3e9323cef9b214d5c02dca1237082711ae08dff572cdd691bf010
3
+ metadata.gz: 79e8cb644aa929ab313099282285e9f3aa2db151144efc8b07ff4a774fccc80d
4
+ data.tar.gz: a175016151807bad144be44ad951ee561629f697d4b8ef009f796d52ef084b71
5
5
  SHA512:
6
- metadata.gz: 9726fcc6cc5a07221aed121af8ab7e1e47ed5157cbe57ea8935e0d2f9db6dd9af7239c86bfc57f36dc6e3894ab51cdc6bd2c10dd448dd322d2fe8bfc809d67fe
7
- data.tar.gz: 630e3203ca6dd8307b60564827c10a44f643ef563ed3d6731b6a74f4f2312f8c3ef0ceb027093d25d8cc5baa58f769db8c4c0db3e031b084eb48131387add759
6
+ metadata.gz: 9e90acbbd5aeb4e9bfcca226f1d3850f8e631df9ee1241775ded0d72d63b87210b6565923ef39c3c91fe2b1430476ecdc3f5c7af7a2396e7235d1ba235c9378f
7
+ data.tar.gz: c356ff0c2af1ffd8dac446667dcb12079abcc4cf36bebafdc83e834245316af9ebedb888f5f6ca4c8f33f460d619c6f0a5a566b0717a06f9b12f4270070e5fd0
data/README.md CHANGED
@@ -4,7 +4,9 @@ Welcome to your new gem! In this directory, you'll find the files you need to be
4
4
 
5
5
  Yieldable is meta-mixin, which makes your module, class or it's instance to respond to method +to_proc+, for example, to easily build instances during iteration:
6
6
 
7
- ["1", "2", "3"].map(&SomeObject)
7
+ ```ruby
8
+ ["1", "2", "3"].map(&SomeObject)
9
+ ```
8
10
 
9
11
  ## Installation
10
12
 
@@ -24,36 +26,45 @@ Or install it yourself as:
24
26
 
25
27
  ## Usage
26
28
 
27
- It is 2 different ways to use this module: +extend+ or +prepend+ it to your class.
29
+ It is 2 different ways to use this module: `extend` or `prepend` it to your class.
28
30
 
29
- == <tt>extend Yieldable</tt>
31
+ ### `extend Yieldable`
30
32
 
31
- class SomeObject
32
- extend Yieldable # => singleton_class.to_proc = SomeObject.method(:call).to_proc
33
- end
33
+ ```ruby
34
+ class SomeObject
35
+ extend Yieldable
36
+ # => singleton_class.to_proc = SomeObject.method(:call).to_proc
37
+ end
38
+ ```
34
39
 
35
- This way defines an attribute reader +to_proc+ in a singleton class.
36
- It sets a proc only once for a class, so it will not generate a new +Proc+ object
37
- every time, like if you would use just a <tt>method(:call).to_proc</tt>.
38
- By default it uses the +call+ class method as a source method for a proc. You
39
- can change the source method name by using brackets:
40
+ This way defines an attribute reader `#to_proc` in a singleton class.
41
+ It sets a proc only once for a class, so it will not generate a new `Proc` object
42
+ every time, like if you would use just a `method(:call).to_proc`.
43
+ By default it uses the `call` class method as a source method for a proc.
40
44
 
41
- class SomeObject
42
- extend Yieldable[:new] # => singleton_class.to_proc = SomeObject.method(:new).to_proc
43
- end
45
+ You can change the source method name by using brackets:
44
46
 
45
- It's better to ensure that a source method is defined _before_ extending a class with +Yieldable+.
46
- In the other way it will add the +singletone_method_added+ hook and wait. After a source method
47
+ ```ruby
48
+ class SomeObject
49
+ extend Yieldable[:new]
50
+ # => singleton_class.to_proc = SomeObject.method(:new).to_proc
51
+ end
52
+ ```
53
+
54
+ It's better to ensure that a source method is defined _before_ extending a class with `Yieldable`.
55
+ In the other way it will add the `Yieldable::WaitMethodDefinition.singletone_method_added` hook and wait. After a source method
47
56
  will be added, the hook method will be removed.
48
57
 
49
- You can avoid to removing the hook with an optional <tt>once: false</tt> passed into the brackets:
58
+ You can avoid to removing the hook with an optional `once: false` passed into the brackets:
50
59
 
51
- extend Yieldable[:new, once: false]
60
+ ```ruby
61
+ extend Yieldable[:new, once: false]
62
+ ```
52
63
 
53
- == <tt>prepend Yieldable</tt>
64
+ ### `prepend Yieldable`
54
65
 
55
- This way defines a +to_proc+ instance method once for a class, but a proc will be generated once for
56
- each object. You can also use a brackets like within an +extend+ way.
66
+ This way defines a `#to_proc` instance method once for a class, but a proc will be generated once for
67
+ each object. You can also use a brackets like within an `extend` way.
57
68
 
58
69
 
59
70
  ## Development
@@ -1,3 +1,3 @@
1
1
  module Yieldable
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yieldable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Semenov