six 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/six.rb +12 -9
  2. metadata +1 -1
data/lib/six.rb CHANGED
@@ -1,14 +1,10 @@
1
- require "singleton"
2
-
3
- module Six
4
- class Guard
5
- include Singleton
6
-
1
+ class Six
2
+ class << self
7
3
  attr_accessor :rules_packs
8
4
  attr_accessor :current_rule_pack
9
5
 
10
- def initialize
11
- @rules_packs = {}
6
+ def rules_packs
7
+ @rules_packs ||= {}
12
8
  end
13
9
 
14
10
  def use(name)
@@ -21,7 +17,10 @@ module Six
21
17
  end
22
18
 
23
19
  def remove_pack(name)
24
- rules_packs.delete(name.to_sym)
20
+ if pack_exist?(name)
21
+ @current_rule_pack = nil if rules_packs[name.to_sym] == @current_rule_pack
22
+ rules_packs.delete(name.to_sym)
23
+ end
25
24
  end
26
25
 
27
26
  def valid_rules_object?(object)
@@ -41,5 +40,9 @@ module Six
41
40
  rules_packs.values.map { |rp| rp.allowed(object, subject) }.flatten.include?(action)
42
41
  end
43
42
  end
43
+
44
+ def reset_use
45
+ @current_rule_pack = nil
46
+ end
44
47
  end
45
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: six
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: