tenacity 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/EXTEND.rdoc +11 -1
- data/README.rdoc +4 -1
- data/Rakefile +20 -9
- data/history.txt +21 -0
- data/lib/tenacity.rb +12 -4
- data/lib/tenacity/associates_proxy.rb +67 -0
- data/lib/tenacity/association.rb +19 -6
- data/lib/tenacity/associations/has_many.rb +6 -0
- data/lib/tenacity/class_methods.rb +52 -1
- data/lib/tenacity/instance_methods.rb +7 -3
- data/lib/tenacity/orm_ext/activerecord.rb +30 -13
- data/lib/tenacity/orm_ext/couchrest.rb +140 -0
- data/lib/tenacity/orm_ext/datamapper.rb +139 -0
- data/lib/tenacity/orm_ext/mongo_mapper.rb +88 -80
- data/lib/tenacity/orm_ext/mongoid.rb +108 -0
- data/lib/tenacity/orm_ext/sequel.rb +134 -0
- data/lib/tenacity/version.rb +1 -1
- data/tenacity.gemspec +14 -3
- data/test/association_features/belongs_to_test.rb +42 -0
- data/test/association_features/has_many_test.rb +110 -0
- data/test/association_features/has_one_test.rb +41 -0
- data/test/associations/belongs_to_test.rb +36 -127
- data/test/associations/has_many_test.rb +77 -196
- data/test/associations/has_one_test.rb +22 -84
- data/test/core/classmethods_test.rb +24 -22
- data/test/fixtures/active_record_has_many_target.rb +10 -0
- data/test/fixtures/active_record_has_one_target.rb +10 -0
- data/test/fixtures/{active_record_nuts.rb → active_record_nut.rb} +0 -0
- data/test/fixtures/active_record_object.rb +17 -0
- data/test/fixtures/couch_rest_door.rb +0 -2
- data/test/fixtures/couch_rest_has_many_target.rb +12 -0
- data/test/fixtures/couch_rest_has_one_target.rb +12 -0
- data/test/fixtures/couch_rest_object.rb +19 -0
- data/test/fixtures/couch_rest_windshield.rb +0 -2
- data/test/fixtures/data_mapper_has_many_target.rb +19 -0
- data/test/fixtures/data_mapper_has_one_target.rb +19 -0
- data/test/fixtures/data_mapper_object.rb +20 -0
- data/test/fixtures/mongo_mapper_ash_tray.rb +0 -2
- data/test/fixtures/mongo_mapper_dashboard.rb +0 -2
- data/test/fixtures/mongo_mapper_has_many_target.rb +11 -0
- data/test/fixtures/mongo_mapper_has_one_target.rb +11 -0
- data/test/fixtures/mongo_mapper_object.rb +18 -0
- data/test/fixtures/mongo_mapper_vent.rb +0 -2
- data/test/fixtures/mongo_mapper_wheel.rb +0 -2
- data/test/fixtures/mongoid_has_many_target.rb +13 -0
- data/test/fixtures/mongoid_has_one_target.rb +13 -0
- data/test/fixtures/mongoid_object.rb +20 -0
- data/test/fixtures/sequel_has_many_target.rb +10 -0
- data/test/fixtures/sequel_has_one_target.rb +10 -0
- data/test/fixtures/sequel_object.rb +17 -0
- data/test/helpers/active_record_test_helper.rb +51 -0
- data/test/helpers/data_mapper_test_helper.rb +44 -0
- data/test/helpers/mongoid_test_helper.rb +21 -0
- data/test/helpers/sequel_test_helper.rb +60 -0
- data/test/orm_ext/activerecord_test.rb +55 -35
- data/test/orm_ext/couchrest_test.rb +66 -46
- data/test/orm_ext/datamapper_test.rb +112 -0
- data/test/orm_ext/mongo_mapper_test.rb +64 -44
- data/test/orm_ext/mongoid_test.rb +121 -0
- data/test/orm_ext/sequel_test.rb +113 -0
- data/test/test_helper.rb +87 -11
- metadata +159 -59
- data/lib/tenacity/orm_ext/couchrest/couchrest_extended_document.rb +0 -42
- data/lib/tenacity/orm_ext/couchrest/couchrest_model.rb +0 -44
- data/lib/tenacity/orm_ext/couchrest/tenacity_class_methods.rb +0 -43
- data/lib/tenacity/orm_ext/couchrest/tenacity_instance_methods.rb +0 -21
- data/test/fixtures/couch_rest_radio.rb +0 -10
- data/test/fixtures/mongo_mapper_button.rb +0 -6
@@ -1,43 +0,0 @@
|
|
1
|
-
module CouchRest
|
2
|
-
module TenacityClassMethods #:nodoc:
|
3
|
-
def _t_find(id)
|
4
|
-
get(id)
|
5
|
-
end
|
6
|
-
|
7
|
-
def _t_find_bulk(ids)
|
8
|
-
return [] if ids.nil? || ids.empty?
|
9
|
-
|
10
|
-
docs = []
|
11
|
-
result = database.get_bulk ids
|
12
|
-
result['rows'].each do |row|
|
13
|
-
docs << (row['doc'].nil? ? nil : create_from_database(row['doc']))
|
14
|
-
end
|
15
|
-
docs.reject { |doc| doc.nil? }
|
16
|
-
end
|
17
|
-
|
18
|
-
def _t_find_first_by_associate(property, id)
|
19
|
-
self.send("by_#{property}", :key => id.to_s).first
|
20
|
-
end
|
21
|
-
|
22
|
-
def _t_find_all_by_associate(property, id)
|
23
|
-
self.send("by_#{property}", :key => id.to_s)
|
24
|
-
end
|
25
|
-
|
26
|
-
def _t_initialize_has_many_association(association)
|
27
|
-
unless self.respond_to?(association.foreign_keys_property)
|
28
|
-
property association.foreign_keys_property, :type => [String]
|
29
|
-
view_by association.foreign_keys_property
|
30
|
-
after_save { |record| record.class._t_save_associates(record, association) if record.class.respond_to?(:_t_save_associates) }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def _t_initialize_belongs_to_association(association)
|
35
|
-
property_name = association.foreign_key
|
36
|
-
unless self.respond_to?(property_name)
|
37
|
-
property property_name, :type => String
|
38
|
-
view_by property_name
|
39
|
-
before_save { |record| _t_stringify_belongs_to_value(record, association) if self.respond_to?(:_t_stringify_belongs_to_value) }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module CouchRest
|
2
|
-
module TenacityInstanceMethods #:nodoc:
|
3
|
-
def _t_reload
|
4
|
-
new_doc = database.get(self.id)
|
5
|
-
self.clear
|
6
|
-
new_doc.each { |k,v| self[k] = new_doc[k] }
|
7
|
-
end
|
8
|
-
|
9
|
-
def _t_associate_many(association, associate_ids)
|
10
|
-
self.send(association.foreign_keys_property + '=', associate_ids.map { |associate_id| associate_id.to_s })
|
11
|
-
end
|
12
|
-
|
13
|
-
def _t_get_associate_ids(association)
|
14
|
-
self.send(association.foreign_keys_property) || []
|
15
|
-
end
|
16
|
-
|
17
|
-
def _t_clear_associates(association)
|
18
|
-
self.send(association.foreign_keys_property + '=', [])
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|