maintain 0.1.8 → 0.1.9
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 +1 -1
- data/lib/maintain/maintainer.rb +1 -1
- data/maintain.gemspec +2 -2
- data/spec/active_record_spec.rb +15 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
data/lib/maintain/maintainer.rb
CHANGED
@@ -21,7 +21,7 @@ module Maintain
|
|
21
21
|
end
|
22
22
|
# Now define the state
|
23
23
|
if @active_record && method_free?(name, true)
|
24
|
-
conditions = {:conditions => {@attribute => options.map{|value| states[value]}}}
|
24
|
+
conditions = {:conditions => {@attribute => options.map{|value| states[value][:value].is_a?(Symbol) ? states[value][:value].to_s : states[value][:value] }}}
|
25
25
|
if defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::STRING >= "3"
|
26
26
|
maintainee.scope name, conditions
|
27
27
|
else
|
data/maintain.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{maintain}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Flip Sasser"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-06}
|
13
13
|
s.description = %q{
|
14
14
|
Maintain is a simple state machine mixin for Ruby objects. It supports comparisons, bitmasks,
|
15
15
|
and hooks that really work. It can be used for multiple attributes and will always do its best to
|
data/spec/active_record_spec.rb
CHANGED
@@ -34,7 +34,10 @@ if proceed
|
|
34
34
|
ActiveMaintainTest.maintain :status do
|
35
35
|
state :new, :default => true
|
36
36
|
state :old
|
37
|
-
|
37
|
+
state :foo
|
38
|
+
state :bar
|
39
|
+
aggregate :everything, :as => [:new, :old, :foo, :bar]
|
40
|
+
aggregate :fakes, :as => [:foo, :bar]
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
@@ -68,6 +71,17 @@ if proceed
|
|
68
71
|
ActiveMaintainTest.should respond_to(:everything)
|
69
72
|
ActiveMaintainTest.everything.should respond_to(:each)
|
70
73
|
end
|
74
|
+
|
75
|
+
it "should return the correct collections on aggregates" do
|
76
|
+
ActiveMaintainTest.destroy_all
|
77
|
+
one = ActiveMaintainTest.create(:status => :foo)
|
78
|
+
two = ActiveMaintainTest.create(:status => :bar)
|
79
|
+
three = ActiveMaintainTest.create(:status => :new)
|
80
|
+
four = ActiveMaintainTest.create(:status => :old)
|
81
|
+
ActiveMaintainTest.fakes.should == [one, two]
|
82
|
+
ActiveMaintainTest.everything.should == [one, two, three, four]
|
83
|
+
end
|
84
|
+
|
71
85
|
end
|
72
86
|
end
|
73
87
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 9
|
9
|
+
version: 0.1.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Flip Sasser
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-06 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|