decorations 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -9
- data/lib/decorations.rb +0 -13
- data/lib/decorations/version.rb +1 -1
- metadata +1 -2
- data/LICENSE +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d114bfb9a30d1f5a382ea785ed9989beb4b02cdeb9961596cdaee14c1a9d74e
|
4
|
+
data.tar.gz: fbe4643ebba0cf10637fd5784d1c891494eec3b1657768f8e51b311ca4f9727e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 736e20f6624e3043951d689a78d69acf531928e9ae77544eab1e763975be528d44c9ceea6319339d8f542bd2ce649b8722785d8a27b9a948356b9871ff8075b1
|
7
|
+
data.tar.gz: 8fb9c4dc70da6d5faf762ec3ec9e99cb91a07d8beb58f45c8c803eaafbacd18c9d6011ba850b0b97497960804c0d3fc716e736a9dc89d3cfa7eb17c3cc8ae69f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -23,6 +23,8 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
+
**Note:** You can only decorate instance methods. The Ruby callback hook is only executed on instance method definions, not class methods.
|
27
|
+
|
26
28
|
Create a class that will have decorated methods and create decator classes to be executed around the decorated method.
|
27
29
|
|
28
30
|
```ruby
|
@@ -71,7 +73,7 @@ app.perform_task_with_a_block { puts 'in a block' }
|
|
71
73
|
|
72
74
|
You can also pass in parameters to decorator methods:
|
73
75
|
|
74
|
-
```
|
76
|
+
```ruby
|
75
77
|
class AnotherDecorator < Decorator
|
76
78
|
def initialize(some, params)
|
77
79
|
@some = some
|
@@ -104,14 +106,6 @@ demo.another_method
|
|
104
106
|
# running puts in yet another method
|
105
107
|
# value 2
|
106
108
|
# => nil
|
107
|
-
|
108
|
-
```
|
109
|
-
|
110
|
-
When testing decorated methods, execute `Decorations.disable` before requiring your source files. In your spec\_helper.rb add the following lines before your library is loaded:
|
111
|
-
|
112
|
-
```ruby
|
113
|
-
require 'decorations'
|
114
|
-
Decorations.disable
|
115
109
|
```
|
116
110
|
|
117
111
|
## Development
|
data/lib/decorations.rb
CHANGED
@@ -20,19 +20,6 @@ module Decorations
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
##
|
24
|
-
# Disables injecting decorations. Necessary for testing decorated methods
|
25
|
-
#
|
26
|
-
# @return [Void]
|
27
|
-
#
|
28
|
-
# @example
|
29
|
-
# Decorations.disable
|
30
|
-
#
|
31
|
-
# @api public
|
32
|
-
def self.disable
|
33
|
-
@disabled = true
|
34
|
-
end
|
35
|
-
|
36
23
|
##
|
37
24
|
# Decorates a method execute's the klass' #call method around the decorated method
|
38
25
|
#
|
data/lib/decorations/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decorations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Shields
|
@@ -150,7 +150,6 @@ files:
|
|
150
150
|
- CODE_OF_CONDUCT.md
|
151
151
|
- Gemfile
|
152
152
|
- Gemfile.lock
|
153
|
-
- LICENSE
|
154
153
|
- LICENSE.txt
|
155
154
|
- README.md
|
156
155
|
- Rakefile
|
data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2019 John Shields
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|