darthjee-core_ext 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/OBJECT_README.md +50 -0
- data/README.md +2 -0
- data/lib/darthjee/core_ext/object/default_value.rb +16 -0
- data/lib/darthjee/core_ext/object.rb +2 -0
- data/lib/darthjee/core_ext/version.rb +1 -1
- data/spec/lib/object/default_value_spe.rb +31 -0
- data/spec/support/models/default_value.rb +4 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b584506156a0622988d8fe4b00681f318ebc9660
|
4
|
+
data.tar.gz: 3f554744e539f3440408f9d971bdd45b5dbf24f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 428fc4e08889758330f638d25299cb5b26aee30cf284b3e7fcf548872e972e59dc27f61a69d753ec845e32ae4be0a17c0134ffcc3b7629632d0ceb91caf67d1a
|
7
|
+
data.tar.gz: b2fd1bac68f74aeabe0a4e0095c0d1db5a5364e0ea36cb3929c79f9633f110cfb465965fb01f661f85ec0879da0a02fd3d6805acc293bfff836922ff69538ca7
|
data/OBJECT_README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
## Object
|
2
|
+
|
3
|
+
### .default_value
|
4
|
+
Adds a method with default value
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
class TheClass
|
8
|
+
default_value :the_method, 10
|
9
|
+
end.new.the_method
|
10
|
+
```
|
11
|
+
|
12
|
+
will return
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
10
|
16
|
+
```
|
17
|
+
|
18
|
+
### .default_values
|
19
|
+
Add several methods with single return value
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
class TheIntermediateChild < TheParent
|
23
|
+
default_values :is_child?, :is_final?, true
|
24
|
+
end.new.is_child?
|
25
|
+
```
|
26
|
+
|
27
|
+
will return
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
true
|
31
|
+
```
|
32
|
+
|
33
|
+
### #is_any?
|
34
|
+
returns if the object is an instance of any of the given classes
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
1.is_any?(String, Symbol)
|
38
|
+
```
|
39
|
+
returns
|
40
|
+
```ruby
|
41
|
+
false
|
42
|
+
```
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
1.is_any?(String, Symbol, Numeric)
|
46
|
+
```
|
47
|
+
returns
|
48
|
+
```ruby
|
49
|
+
false
|
50
|
+
```
|
data/README.md
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Object do
|
4
|
+
describe '.default_value' do
|
5
|
+
subject { DefaultValue.new }
|
6
|
+
|
7
|
+
it 'accepts default value' do
|
8
|
+
expect(subject.x).to eq(10)
|
9
|
+
end
|
10
|
+
|
11
|
+
it do
|
12
|
+
expect(Object).not_to respond_to(:default_value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.default_values' do
|
17
|
+
subject { DefaultValue.new }
|
18
|
+
|
19
|
+
it 'accepts default values' do
|
20
|
+
expect(subject.y).to eq(20)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'accepts default values' do
|
24
|
+
expect(subject.z).to eq(20)
|
25
|
+
end
|
26
|
+
|
27
|
+
it do
|
28
|
+
expect(Object).not_to respond_to(:default_values)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darthjee-core_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darthjee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- Gemfile
|
138
138
|
- HASH_README.md
|
139
139
|
- LICENSE
|
140
|
+
- OBJECT_README.md
|
140
141
|
- README.md
|
141
142
|
- Rakefile
|
142
143
|
- SYMBOL_README.md
|
@@ -155,6 +156,7 @@ files:
|
|
155
156
|
- lib/darthjee/core_ext/hash/value_changer.rb
|
156
157
|
- lib/darthjee/core_ext/numeric.rb
|
157
158
|
- lib/darthjee/core_ext/object.rb
|
159
|
+
- lib/darthjee/core_ext/object/default_value.rb
|
158
160
|
- lib/darthjee/core_ext/symbol.rb
|
159
161
|
- lib/darthjee/core_ext/time.rb
|
160
162
|
- lib/darthjee/core_ext/version.rb
|
@@ -165,10 +167,12 @@ files:
|
|
165
167
|
- spec/lib/hash/key_changer_spec.rb
|
166
168
|
- spec/lib/hash_spec.rb
|
167
169
|
- spec/lib/numeric_spec.rb
|
170
|
+
- spec/lib/object/default_value_spe.rb
|
168
171
|
- spec/lib/object_spec.rb
|
169
172
|
- spec/lib/symbol_spec.rb
|
170
173
|
- spec/lib/time_spec.rb
|
171
174
|
- spec/spec_helper.rb
|
175
|
+
- spec/support/models/default_value.rb
|
172
176
|
- spec/support/models/hash/value_changer/dummy.rb
|
173
177
|
- spec/support/models/hash/value_changer/dummy_iteractor.rb
|
174
178
|
- spec/support/shared_examples/array_random.rb
|
@@ -216,10 +220,12 @@ test_files:
|
|
216
220
|
- spec/lib/hash/key_changer_spec.rb
|
217
221
|
- spec/lib/hash_spec.rb
|
218
222
|
- spec/lib/numeric_spec.rb
|
223
|
+
- spec/lib/object/default_value_spe.rb
|
219
224
|
- spec/lib/object_spec.rb
|
220
225
|
- spec/lib/symbol_spec.rb
|
221
226
|
- spec/lib/time_spec.rb
|
222
227
|
- spec/spec_helper.rb
|
228
|
+
- spec/support/models/default_value.rb
|
223
229
|
- spec/support/models/hash/value_changer/dummy.rb
|
224
230
|
- spec/support/models/hash/value_changer/dummy_iteractor.rb
|
225
231
|
- spec/support/shared_examples/array_random.rb
|