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.
@@ -1,4 +1,5 @@
1
1
  require_relative 'hash/dotted_paths'
2
+ require_relative 'hash/except'
2
3
  require_relative 'hash/key_transforms'
3
4
  require_relative 'hash/reverse_merge'
4
5
  require_relative 'hash/slice'
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Buff
2
2
  module Extensions
3
- VERSION = "0.3.1"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  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.3.1
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-17 00:00:00.000000000 Z
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: -1109470167782244660
230
+ hash: -1420043020667632926
230
231
  requirements: []
231
232
  rubyforge_project:
232
233
  rubygems_version: 1.8.23