buff-extensions 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/buff/extensions/hash.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Buff
|
2
|
+
module Extensions::Hash
|
3
|
+
# Borrowd and modified from
|
4
|
+
# {https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/except.rb}
|
5
|
+
module Except
|
6
|
+
# Return a hash that includes everything but the given keys. This is useful for
|
7
|
+
# limiting a set of parameters to everything but a few known toggles:
|
8
|
+
#
|
9
|
+
# @person.update(params[:person].except(:admin))
|
10
|
+
def except(*keys)
|
11
|
+
dup.except!(*keys)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Replaces the hash without the given keys.
|
15
|
+
def except!(*keys)
|
16
|
+
keys.each { |key| delete(key) }
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Hash
|
24
|
+
include Buff::Extensions::Hash::Except
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buff-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: buff-ruby_engine
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- lib/buff/extensions/boolean.rb
|
194
194
|
- lib/buff/extensions/hash.rb
|
195
195
|
- lib/buff/extensions/hash/dotted_paths.rb
|
196
|
+
- lib/buff/extensions/hash/except.rb
|
196
197
|
- lib/buff/extensions/hash/key_transforms.rb
|
197
198
|
- lib/buff/extensions/hash/reverse_merge.rb
|
198
199
|
- lib/buff/extensions/hash/slice.rb
|
@@ -226,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
227
|
version: '0'
|
227
228
|
segments:
|
228
229
|
- 0
|
229
|
-
hash: -
|
230
|
+
hash: -1420043020667632926
|
230
231
|
requirements: []
|
231
232
|
rubyforge_project:
|
232
233
|
rubygems_version: 1.8.23
|