acts_as_statused 1.0.0 → 1.0.1

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/acts_as_statused.rb +10 -3
  2. metadata +2 -2
@@ -16,6 +16,12 @@ module ActiveRecord #:nodoc:
16
16
  valid_status = []
17
17
  valid_statuses = options[:only] if options.is_a?(Hash)
18
18
 
19
+ class_name = options.to_s if options.is_a?(Symbol) || options.is_a?(String)
20
+ class_name = options[:class_name] if options.is_a?(Hash)
21
+ class_name = "Status" if class_name.blank?
22
+
23
+ #puts "class_name = #{class_name}"
24
+
19
25
  class_eval do
20
26
  belongs_to :status
21
27
 
@@ -26,15 +32,16 @@ module ActiveRecord #:nodoc:
26
32
  end
27
33
 
28
34
  def status
29
- Status.get(self.status_id)
35
+ eval "#{class_name}.get(self.status_id)"
30
36
  end
31
37
 
32
38
  def has_status_changed?
33
39
  return self.previous_status != self.status
34
40
  end
35
41
 
36
- begin
37
- Status.find(:all).each do |status| #get all the statuses in the db.
42
+ begin
43
+ rows = eval "#{class_name}.find(:all)"
44
+ rows.each do |status| #get all the statuses in the db.
38
45
  # only define valid statuses
39
46
  # EX: acts_as_statused :only => ['active', 'inactive', 'pending']
40
47
  next unless valid_statuses.blank? || valid_statuses.include?(status.name)
metadata CHANGED
@@ -3,9 +3,9 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: acts_as_statused
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
6
+ version: 1.0.1
7
7
  date: 2007-02-27 00:00:00 -05:00
8
- summary: acts_as_statused
8
+ summary: Acts as Statused
9
9
  require_paths:
10
10
  - lib
11
11
  - lib