acts_as_status_for 3.0.3 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
17
17
  gem.name = "acts_as_status_for"
18
18
  gem.homepage = "http://github.com/robotarmy/acts_as_status_for"
19
19
  gem.license = "MIT"
20
- gem.summary = %Q{Acts as Status For a list of events - did something occur? or not? with scoped finder?}
21
- gem.description = %Q{Given a list of datetime _at attributes }
20
+ gem.summary = %Q{Acts as Status For a list of events - did something occur? or not? with scoped finders and dynamic class scope - written for rails 3}
21
+ gem.description = %Q{Given a list of datetime _at attributes allow an activerecord object to query status, change status and hold multiple states, these states can be used to build state machines or other constructs. }
22
22
  gem.email = "github.com@robotarmyma.de"
23
23
  gem.authors = ["Curtis Schofield"]
24
24
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.3
1
+ 3.0.5
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{acts_as_status_for}
8
- s.version = "3.0.3"
8
+ s.version = "3.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Curtis Schofield"]
12
- s.date = %q{2011-06-29}
13
- s.description = %q{Given a list of datetime _at attributes }
12
+ s.date = %q{2011-06-30}
13
+ s.description = %q{Given a list of datetime _at attributes allow an activerecord object to query status, change status and hold multiple states, these states can be used to build state machines or other constructs. }
14
14
  s.email = %q{github.com@robotarmyma.de}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.licenses = ["MIT"]
36
36
  s.require_paths = ["lib"]
37
37
  s.rubygems_version = %q{1.5.2}
38
- s.summary = %q{Acts as Status For a list of events - did something occur? or not? with scoped finder?}
38
+ s.summary = %q{Acts as Status For a list of events - did something occur? or not? with scoped finders and dynamic class scope - written for rails 3}
39
39
 
40
40
  if s.respond_to? :specification_version then
41
41
  s.specification_version = 3
@@ -21,6 +21,34 @@ module ActsAsStatusFor
21
21
  STDERR.puts "Arel could not find #{state}_at in the database - skipping installation of acts_as_status"
22
22
  end
23
23
 
24
+ def status_including_method(method)
25
+ if method =~ /status_including_(.+)/
26
+ $1
27
+ else
28
+ nil
29
+ end
30
+ end
31
+
32
+ def respond_to_missing?(method,include_private)
33
+ ! status_including_method(method).nil?
34
+ end
35
+
36
+ def statuses_including(status_list)
37
+ has_condition = self.class
38
+ status_list.each do |state|
39
+ has_condition = has_condition.where(self.class.arel_table["#{state}_at".to_sym].not_eq(nil))
40
+ end
41
+ has_condition
42
+ end
43
+
44
+ def method_missing(method,*rest,&block)
45
+ includes = status_including_method(method)
46
+ if not includes.blank?
47
+ statuses_including(includes.split('_and_'))
48
+ else
49
+ super
50
+ end
51
+ end
24
52
 
25
53
  #
26
54
  # having the state means that the
@@ -98,34 +126,6 @@ module ActsAsStatusFor
98
126
  end
99
127
 
100
128
  module InstanceMethods
101
- def status_including_method(method)
102
- if method =~ /status_including_(.+)/
103
- $1
104
- else
105
- nil
106
- end
107
- end
108
-
109
- def respond_to_missing?(method,include_private)
110
- ! status_including_method(method).nil?
111
- end
112
-
113
- def statuses_including(status_list)
114
- has_condition = self.class
115
- status_list.each do |state|
116
- has_condition = has_condition.where(self.class.arel_table["#{state}_at".to_sym].not_eq(nil))
117
- end
118
- has_condition
119
- end
120
-
121
- def method_missing(method,*rest,&block)
122
- includes = status_including_method(method)
123
- if not includes.blank?
124
- statuses_including(includes.split('_and_'))
125
- else
126
- super
127
- end
128
- end
129
129
 
130
130
  def current_status
131
131
  status.split(' ').first or ''
@@ -83,25 +83,25 @@ describe ActsAsStatusFor do
83
83
  subject.respond_to? :status_including_archived
84
84
  end
85
85
  it "archived" do
86
- subject.status_including_archived.should_not include(subject)
86
+ subject.class.status_including_archived.should_not include(subject)
87
87
  subject.archived!
88
- subject.status_including_archived.should include(subject)
88
+ subject.class.status_including_archived.should include(subject)
89
89
  end
90
90
  it "archived_and_featured" do
91
- subject.status_including_archived_and_featured.should_not include(subject)
91
+ subject.class.status_including_archived_and_featured.should_not include(subject)
92
92
  subject.archived!
93
- subject.status_including_archived_and_featured.should_not include(subject)
93
+ subject.class.status_including_archived_and_featured.should_not include(subject)
94
94
  subject.featured!
95
- subject.status_including_archived_and_featured.should include(subject)
95
+ subject.class.status_including_archived_and_featured.should include(subject)
96
96
  end
97
97
  it "archived_and_featured_and_on_hold" do
98
- subject.status_including_archived_and_featured_and_on_hold.should_not include(subject)
98
+ subject.class.status_including_archived_and_featured_and_on_hold.should_not include(subject)
99
99
  subject.archived!
100
- subject.status_including_archived_and_featured_and_on_hold.should_not include(subject)
100
+ subject.class.status_including_archived_and_featured_and_on_hold.should_not include(subject)
101
101
  subject.featured!
102
- subject.status_including_archived_and_featured_and_on_hold.should_not include(subject)
102
+ subject.class.status_including_archived_and_featured_and_on_hold.should_not include(subject)
103
103
  subject.on_hold!
104
- subject.status_including_archived_and_featured_and_on_hold.should include(subject)
104
+ subject.class.status_including_archived_and_featured_and_on_hold.should include(subject)
105
105
  end
106
106
  end
107
107
  context "#status" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: acts_as_status_for
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.0.3
5
+ version: 3.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Curtis Schofield
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-29 00:00:00 -07:00
13
+ date: 2011-06-30 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -79,7 +79,7 @@ dependencies:
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: *id006
82
- description: "Given a list of datetime _at attributes "
82
+ description: "Given a list of datetime _at attributes allow an activerecord object to query status, change status and hold multiple states, these states can be used to build state machines or other constructs. "
83
83
  email: github.com@robotarmyma.de
84
84
  executables: []
85
85
 
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- hash: 550898432098812955
119
+ hash: -599148864471119160
120
120
  segments:
121
121
  - 0
122
122
  version: "0"
@@ -132,6 +132,6 @@ rubyforge_project:
132
132
  rubygems_version: 1.5.2
133
133
  signing_key:
134
134
  specification_version: 3
135
- summary: Acts as Status For a list of events - did something occur? or not? with scoped finder?
135
+ summary: Acts as Status For a list of events - did something occur? or not? with scoped finders and dynamic class scope - written for rails 3
136
136
  test_files: []
137
137