forbidium 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -6
- data/lib/forbidium/allow.rb +1 -0
- data/lib/forbidium/core_ext/hash.rb +1 -0
- data/lib/forbidium/forbid.rb +1 -0
- data/lib/forbidium/forbidium.rb +17 -0
- data/lib/forbidium/railtie.rb +1 -0
- data/lib/forbidium/version.rb +1 -1
- data/lib/forbidium.rb +0 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7357a934edea8da3fad3521e262b325f5a074aa2
|
4
|
+
data.tar.gz: 3314c60c18cfe8712cc6554dd30d3ab439320264
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b5426bae95cac10e625fc75fcf5e6c6d84c383808f7fefeb638e255bb6126448db590c85a1a4300181da78ae3b7343db912dbc6704784b612601955fc6e977
|
7
|
+
data.tar.gz: 31bdeb20fa5b6759fd6d007ccab67d96fd4f587dc131fc4f5e043391710d1a48fcab00edbb48754d9bf60c2e7c6700fec74d9381c9ac8da68f6c2086acd00706
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Forbidium
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Filter hashes by setting allowed or forbidden values for specific keys.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -21,9 +19,23 @@ Or install it yourself as:
|
|
21
19
|
$ gem install forbidium
|
22
20
|
|
23
21
|
## Usage
|
22
|
+
```ruby
|
23
|
+
hash = { one: 'one', two: 'two' }
|
24
|
+
|
25
|
+
hash.forbid(one: 'one') # => { two: 'two' }
|
26
|
+
|
27
|
+
hash.allow(one: 'two') # => { two: 'two' }
|
28
|
+
|
29
|
+
hash.allow(one: ['one', 'two']) # => { one: 'one', two: 'two' }
|
24
30
|
|
25
|
-
|
31
|
+
hash.forbid(one: ['one', 'two']) # => { two: 'two' }
|
26
32
|
|
33
|
+
hash.allow!(one: 'two') # => { two: 'two' }
|
34
|
+
|
35
|
+
hash.forbid!(two: 'two') # => {}
|
36
|
+
|
37
|
+
hash # => {}
|
38
|
+
```
|
27
39
|
## Development
|
28
40
|
|
29
41
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -32,10 +44,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
44
|
|
33
45
|
## Contributing
|
34
46
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/msimonborg/forbidium.
|
36
48
|
|
37
49
|
|
38
50
|
## License
|
39
51
|
|
40
52
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/lib/forbidium/allow.rb
CHANGED
data/lib/forbidium/forbid.rb
CHANGED
data/lib/forbidium/forbidium.rb
CHANGED
@@ -3,6 +3,23 @@
|
|
3
3
|
require 'forbidium/allow'
|
4
4
|
require 'forbidium/forbid'
|
5
5
|
|
6
|
+
# Filter hashes by setting allowed or forbidden values for specific keys.
|
7
|
+
#
|
8
|
+
# hash = { one: 'one', two: 'two' }
|
9
|
+
#
|
10
|
+
# hash.forbid(one: 'one') # => { two: 'two' }
|
11
|
+
#
|
12
|
+
# hash.allow(one: 'two') # => { two: 'two' }
|
13
|
+
#
|
14
|
+
# hash.allow(one: ['one', 'two']) # => { one: 'one', two: 'two' }
|
15
|
+
#
|
16
|
+
# hash.forbid(one: ['one', 'two']) # => { two: 'two' }
|
17
|
+
#
|
18
|
+
# hash.allow!(one: 'two') # => { two: 'two' }
|
19
|
+
#
|
20
|
+
# hash.forbid!(two: 'two') # => {}
|
21
|
+
#
|
22
|
+
# hash # => {}
|
6
23
|
module Forbidium
|
7
24
|
def self.included(base)
|
8
25
|
[Forbidium::Allow, Forbidium::Forbid].each { |mod| base.include mod }
|
data/lib/forbidium/railtie.rb
CHANGED
data/lib/forbidium/version.rb
CHANGED
data/lib/forbidium.rb
CHANGED