deep_cloneable 1.4.0 → 3.2.1
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.
- checksums.yaml +7 -0
- data/Appraisals +57 -0
- data/CHANGELOG.md +350 -0
- data/Gemfile +8 -7
- data/Gemfile.lock +51 -91
- data/LICENSE +1 -1
- data/Rakefile +8 -33
- data/deep_cloneable.gemspec +18 -55
- data/init.rb +3 -1
- data/lib/deep_cloneable/association_not_found_exception.rb +6 -0
- data/lib/deep_cloneable/deep_clone.rb +207 -0
- data/lib/deep_cloneable/skip_validations.rb +10 -0
- data/lib/deep_cloneable/version.rb +3 -0
- data/lib/deep_cloneable.rb +13 -124
- data/readme.md +242 -0
- metadata +33 -67
- data/.document +0 -5
- data/README.rdoc +0 -78
- data/VERSION +0 -1
- data/test/database.yml +0 -6
- data/test/schema.rb +0 -52
- data/test/test_deep_cloneable.rb +0 -162
- data/test/test_helper.rb +0 -79
data/test/test_helper.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'pp'
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
-
|
8
|
-
require 'active_record'
|
9
|
-
require File.dirname(__FILE__) + '/../init.rb'
|
10
|
-
|
11
|
-
module Animal
|
12
|
-
class Human < ActiveRecord::Base
|
13
|
-
has_many :pigs
|
14
|
-
|
15
|
-
has_many :ownerships
|
16
|
-
has_many :chickens, :through => :ownerships
|
17
|
-
end
|
18
|
-
class Pig < ActiveRecord::Base
|
19
|
-
belongs_to :human
|
20
|
-
end
|
21
|
-
|
22
|
-
class Chicken < ActiveRecord::Base
|
23
|
-
has_many :ownerships
|
24
|
-
has_many :humans, :through => :ownerships
|
25
|
-
end
|
26
|
-
|
27
|
-
class Ownership < ActiveRecord::Base
|
28
|
-
belongs_to :human
|
29
|
-
belongs_to :chicken
|
30
|
-
|
31
|
-
validates_uniqueness_of :chicken_id, :scope => :human_id
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class GoldPiece < ActiveRecord::Base; belongs_to :treasure end
|
36
|
-
class Matey < ActiveRecord::Base; belongs_to :pirate end
|
37
|
-
class Parrot < ActiveRecord::Base; belongs_to :pirate; attr_accessor :cloned_from_id end
|
38
|
-
class BattleShip < ActiveRecord::Base; has_many :pirates, :as => :ship end
|
39
|
-
|
40
|
-
class Pirate < ActiveRecord::Base
|
41
|
-
belongs_to :ship, :polymorphic => true
|
42
|
-
|
43
|
-
has_many :mateys
|
44
|
-
has_many :treasures, :foreign_key => 'owner'
|
45
|
-
has_many :gold_pieces, :through => :treasures
|
46
|
-
has_one :parrot
|
47
|
-
|
48
|
-
attr_accessor :cloned_from_id
|
49
|
-
end
|
50
|
-
|
51
|
-
class Treasure < ActiveRecord::Base
|
52
|
-
belongs_to :pirate, :foreign_key => :owner
|
53
|
-
belongs_to :matey
|
54
|
-
has_many :gold_pieces
|
55
|
-
end
|
56
|
-
|
57
|
-
def load_schema
|
58
|
-
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
59
|
-
ActiveRecord::Base.logger = ActiveSupport::BufferedLogger.new(File.dirname(__FILE__) + "/debug.log")
|
60
|
-
db_adapter = ENV['DB']
|
61
|
-
# no db passed, try one of these fine config-free DBs before bombing.
|
62
|
-
db_adapter ||= begin
|
63
|
-
require 'rubygems'
|
64
|
-
require 'sqlite'
|
65
|
-
'sqlite'
|
66
|
-
rescue MissingSourceFile
|
67
|
-
begin
|
68
|
-
require 'sqlite3'
|
69
|
-
'sqlite3'
|
70
|
-
rescue MissingSourceFile
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
if db_adapter.nil?
|
75
|
-
raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
|
76
|
-
end
|
77
|
-
ActiveRecord::Base.establish_connection(config[db_adapter])
|
78
|
-
load(File.dirname(__FILE__) + "/schema.rb")
|
79
|
-
end
|