Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b48ede2
commit 7a9ad54
Showing
13 changed files
with
49 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'allowable' | ||
require 'forbidium/version' | ||
require 'forbidium/forbidium' | ||
require 'forbidium/core_ext/hash' | ||
require 'forbidium/railtie' if defined? Rails | ||
|
||
# frozen_string_literal: true | ||
|
||
# Filter hashes by setting allowed or forbidden values for specific keys. | ||
# | ||
# hash = { one: 'one', two: 'two' } | ||
# | ||
# hash.forbid(one: 'one') # => { two: 'two' } | ||
# | ||
# hash.allow(one: 'two') # => { two: 'two' } | ||
# | ||
# hash.allow(one: ['one', 'two']) # => { one: 'one', two: 'two' } | ||
# | ||
# hash.forbid(one: ['one', 'two']) # => { two: 'two' } | ||
# | ||
# hash.allow!(one: 'two') # => { two: 'two' } | ||
# | ||
# hash.forbid!(two: 'two') # => {} | ||
# | ||
# hash # => {} | ||
module Forbidium | ||
include Allowable | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Forbidium | ||
VERSION = '1.2.0' | ||
VERSION = '2.0.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Forbidium do | ||
it 'includes Forbidium::Allow and Forbidium::Forbid when included' do | ||
class ForbidiumTestObject; end | ||
describe Allowable do | ||
it 'includes Allowable::Allow and Allowable::Forbid when included' do | ||
class AllowableTestObject; end | ||
|
||
expect(ForbidiumTestObject.include?(Forbidium::Allow)).not_to be true | ||
expect(ForbidiumTestObject.include?(Forbidium::Forbid)).not_to be true | ||
expect(AllowableTestObject.include?(Allowable)).not_to be true | ||
|
||
ForbidiumTestObject.class_eval { include Forbidium } | ||
AllowableTestObject.class_eval { include Forbidium } | ||
|
||
expect(ForbidiumTestObject.include?(Forbidium::Allow)).to be true | ||
expect(ForbidiumTestObject.include?(Forbidium::Forbid)).to be true | ||
expect(AllowableTestObject.include?(Allowable)).to be true | ||
end | ||
|
||
it 'is included in Hash when required' do | ||
expect(Hash.include?(Forbidium)).to be true | ||
it 'Allowable is included in Hash when required' do | ||
expect(Hash.include?(Allowable)).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters