has_alter_ego 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ # 0.0.7 (2010-09-28)
2
+ * non-numeric primary keys are no longer supported
3
+
4
+ # 0.0.6 (2010-09-28)
5
+ * Fixed a type mismatch problem with numeric ids
6
+
1
7
  # 0.0.5 (2010-06-13)
2
8
  * Implemented smart associations, e.g.
3
9
  category_by_name: Sport # => @car.category = Category.find_by_name("Sport")
data/README.md CHANGED
@@ -78,8 +78,8 @@ and you'd automagically have those objects available in your database.
78
78
  Whenever the seed definition changes the objects in the database inherit the changes unless they have been overridden.
79
79
  When a seed object was destroyed in the database it will not be added again.
80
80
 
81
- **Note:** If the table has a numeric primary key has_alter_ego reserves the first n IDs for seed objects (default=1000),
82
- so the next non-seed object will get the ID 1001.
81
+ **Note:** has_alter_ego reserves the first n IDs for seed objects (default=1000), so the next non-seed object will get
82
+ the ID 1001.
83
83
  The number of reserved objects can be set with the optional *:reserved_space* parameter, e.g.
84
84
 
85
85
  has_alter_ego :reserved_space => 5000
@@ -1,7 +1,7 @@
1
1
  class CreateAlterEgos < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :alter_egos do |t|
4
- t.string :alter_ego_object_id
4
+ t.integer :alter_ego_object_id
5
5
  t.string :alter_ego_object_type, :limit => 40
6
6
  t.string :state
7
7
  end
@@ -11,4 +11,4 @@ class CreateAlterEgos < ActiveRecord::Migration
11
11
  def self.down
12
12
  drop_table :alter_egos
13
13
  end
14
- end
14
+ end
@@ -14,7 +14,6 @@ module HasAlterEgo
14
14
  has_one :alter_ego, :as => :alter_ego_object
15
15
  alias_method :save_without_alter_ego, :save
16
16
  alias_method :destroy_without_alter_ego, :destroy
17
- alias_method :alter_ego_with_type_fix, :alter_ego
18
17
  send :include, InstanceMethods
19
18
  reserve_space(opts[:reserved_space])
20
19
  parse_yml
@@ -23,7 +22,6 @@ module HasAlterEgo
23
22
 
24
23
  # Reserve the first n IDs for stubbed objects
25
24
  def reserve_space space
26
- return unless self.columns_hash[self.primary_key].klass == Fixnum
27
25
  return if self.last and self.last[self.primary_key] >= space
28
26
 
29
27
  o = self.new
@@ -53,7 +51,7 @@ module HasAlterEgo
53
51
  end
54
52
  else
55
53
  # Check for destroyed alter_egos
56
- alter_ego = AlterEgo.find_by_alter_ego_object_id_and_alter_ego_object_type(primary_key.to_s, self.name)
54
+ alter_ego = AlterEgo.find_by_alter_ego_object_id_and_alter_ego_object_type(primary_key, self.name)
57
55
  return if alter_ego.try(:state) == "destroyed"
58
56
 
59
57
  db_object = self.new
@@ -97,10 +95,6 @@ module HasAlterEgo
97
95
  end
98
96
 
99
97
  module InstanceMethods
100
- def alter_ego
101
- return AlterEgo.find_by_alter_ego_object_id_and_alter_ego_object_type(self[self.class.primary_key].to_s, self.name)
102
- end
103
-
104
98
  def has_alter_ego?
105
99
  return self.alter_ego.present?
106
100
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_alter_ego
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Andr\xC3\xA9 Duffeck"