maintain 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.4
@@ -12,7 +12,7 @@ module Maintain
12
12
 
13
13
  protected
14
14
  def bitmask_for(states)
15
- Array(states).map{|value| value_for(value) }.sort.inject(0) {|total, mask| total | mask }
15
+ Array(states).compact.map{|value| value_for(value) }.sort.inject(0) {|total, mask| total | mask.to_i }
16
16
  end
17
17
 
18
18
  def compare_value
@@ -100,8 +100,12 @@ module Maintain
100
100
  end
101
101
 
102
102
  def state_value_for(state, value)
103
- if (state.is_a?(String) || state.is_a?(Symbol)) && state_hash = @state.states[state.to_sym]
104
- state_hash[value]
103
+ if (state.is_a?(String) || state.is_a?(Symbol))
104
+ if !state.to_s.strip.empty? && state_hash = @state.states[state.to_sym]
105
+ state_hash[value]
106
+ else
107
+ nil
108
+ end
105
109
  else
106
110
  state
107
111
  end
@@ -97,6 +97,21 @@ if proceed
97
97
  ActiveMaintainTest.last.permissions.add?.should be_true
98
98
  ActiveMaintainTest.last.permissions.delete?.should be_true
99
99
  end
100
+
101
+ it "should allow me to set a blank string as bitmask values" do
102
+ active_maintain_test = ActiveMaintainTest.create(:permissions => '')
103
+ ActiveMaintainTest.last.permissions.should == 0
104
+ end
105
+
106
+ it "should allow me to set an empty array as bitmask values" do
107
+ active_maintain_test = ActiveMaintainTest.create(:permissions => [])
108
+ ActiveMaintainTest.last.permissions.should == 0
109
+ end
110
+
111
+ it "should allow me to set an array with empty strings as bitmask values" do
112
+ active_maintain_test = ActiveMaintainTest.create(:permissions => [''])
113
+ ActiveMaintainTest.last.permissions.should == 0
114
+ end
100
115
  end
101
116
 
102
117
  describe "named_scopes" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maintain
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Flip Sasser