hash_extend 1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -1
- data/lib/hash_extend.rb +1 -4
- data/lib/hash_extend/version.rb +1 -1
- metadata +39 -20
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Extend ruby Hash. No override.
|
4
4
|
|
5
|
+
## Support
|
6
|
+
|
7
|
+
Validate for Ruby 1.9.3 and Ruby ree-1.8.7
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
@@ -252,7 +256,7 @@ Code
|
|
252
256
|
|
253
257
|
```ruby
|
254
258
|
def select_by! *collection
|
255
|
-
self.
|
259
|
+
self.delete_if{ |field, _| !collection.include? field.to_sym }
|
256
260
|
end
|
257
261
|
```
|
258
262
|
|
data/lib/hash_extend.rb
CHANGED
@@ -73,10 +73,7 @@ class Hash
|
|
73
73
|
|
74
74
|
# something like #keep_if, but instead of block, pass collection of keys to select
|
75
75
|
def select_by! *collection
|
76
|
-
self.
|
77
|
-
|
78
|
-
rescue NoMethodError => e
|
79
|
-
raise NoMethodError.new("undefined method `#{ __method__ }' for #{ self.inspect }:#{ self.class }") if e.name == :keep_if
|
76
|
+
self.delete_if{ |field, _| !collection.include? field.to_sym }
|
80
77
|
end
|
81
78
|
|
82
79
|
|
data/lib/hash_extend/version.rb
CHANGED
metadata
CHANGED
@@ -1,23 +1,33 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_extend
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Thomas Petrachi
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2012-10-01 00:00:00 Z
|
13
19
|
dependencies: []
|
20
|
+
|
14
21
|
description: Extend ruby Hash. No override.
|
15
|
-
email:
|
22
|
+
email:
|
16
23
|
- thomas.petrachi@vodeclic.com
|
17
24
|
executables: []
|
25
|
+
|
18
26
|
extensions: []
|
27
|
+
|
19
28
|
extra_rdoc_files: []
|
20
|
-
|
29
|
+
|
30
|
+
files:
|
21
31
|
- .gitignore
|
22
32
|
- Gemfile
|
23
33
|
- LICENSE.txt
|
@@ -28,27 +38,36 @@ files:
|
|
28
38
|
- lib/hash_extend/version.rb
|
29
39
|
homepage: https://github.com/petrachi/hash_extend
|
30
40
|
licenses: []
|
41
|
+
|
31
42
|
post_install_message:
|
32
43
|
rdoc_options: []
|
33
|
-
|
44
|
+
|
45
|
+
require_paths:
|
34
46
|
- lib
|
35
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
48
|
none: false
|
37
|
-
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
|
41
|
-
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
hash: 3
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
57
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
47
65
|
requirements: []
|
66
|
+
|
48
67
|
rubyforge_project:
|
49
68
|
rubygems_version: 1.8.24
|
50
69
|
signing_key:
|
51
70
|
specification_version: 3
|
52
|
-
summary: Adding methods %w{stealth_delete map_values map_keys delete_many insert compact
|
53
|
-
select_by}
|
71
|
+
summary: Adding methods %w{stealth_delete map_values map_keys delete_many insert compact select_by}
|
54
72
|
test_files: []
|
73
|
+
|