datamapper 0.3.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/History.txt +0 -0
  2. data/Manifest.txt +5 -0
  3. data/README.txt +11 -0
  4. data/Rakefile +70 -0
  5. data/lib/datamapper.rb +8 -0
  6. metadata +152 -319
  7. data/CHANGELOG +0 -145
  8. data/FAQ +0 -96
  9. data/MIT-LICENSE +0 -22
  10. data/QUICKLINKS +0 -12
  11. data/README +0 -105
  12. data/environment.rb +0 -62
  13. data/example.rb +0 -156
  14. data/lib/data_mapper.rb +0 -88
  15. data/lib/data_mapper/adapters/abstract_adapter.rb +0 -43
  16. data/lib/data_mapper/adapters/data_object_adapter.rb +0 -480
  17. data/lib/data_mapper/adapters/mysql_adapter.rb +0 -72
  18. data/lib/data_mapper/adapters/postgresql_adapter.rb +0 -258
  19. data/lib/data_mapper/adapters/sql/coersion.rb +0 -134
  20. data/lib/data_mapper/adapters/sql/commands/load_command.rb +0 -545
  21. data/lib/data_mapper/adapters/sql/mappings/associations_set.rb +0 -34
  22. data/lib/data_mapper/adapters/sql/mappings/column.rb +0 -279
  23. data/lib/data_mapper/adapters/sql/mappings/conditions.rb +0 -172
  24. data/lib/data_mapper/adapters/sql/mappings/schema.rb +0 -60
  25. data/lib/data_mapper/adapters/sql/mappings/table.rb +0 -459
  26. data/lib/data_mapper/adapters/sql/quoting.rb +0 -24
  27. data/lib/data_mapper/adapters/sqlite3_adapter.rb +0 -159
  28. data/lib/data_mapper/associations.rb +0 -106
  29. data/lib/data_mapper/associations/belongs_to_association.rb +0 -160
  30. data/lib/data_mapper/associations/has_and_belongs_to_many_association.rb +0 -437
  31. data/lib/data_mapper/associations/has_many_association.rb +0 -283
  32. data/lib/data_mapper/associations/has_n_association.rb +0 -143
  33. data/lib/data_mapper/associations/reference.rb +0 -47
  34. data/lib/data_mapper/attributes.rb +0 -73
  35. data/lib/data_mapper/auto_migrations.rb +0 -36
  36. data/lib/data_mapper/base.rb +0 -17
  37. data/lib/data_mapper/callbacks.rb +0 -107
  38. data/lib/data_mapper/context.rb +0 -112
  39. data/lib/data_mapper/database.rb +0 -234
  40. data/lib/data_mapper/dependency_queue.rb +0 -28
  41. data/lib/data_mapper/embedded_value.rb +0 -145
  42. data/lib/data_mapper/identity_map.rb +0 -47
  43. data/lib/data_mapper/is/tree.rb +0 -121
  44. data/lib/data_mapper/migration.rb +0 -155
  45. data/lib/data_mapper/persistence.rb +0 -852
  46. data/lib/data_mapper/property.rb +0 -310
  47. data/lib/data_mapper/query.rb +0 -164
  48. data/lib/data_mapper/support/blank.rb +0 -35
  49. data/lib/data_mapper/support/connection_pool.rb +0 -117
  50. data/lib/data_mapper/support/enumerable.rb +0 -35
  51. data/lib/data_mapper/support/errors.rb +0 -16
  52. data/lib/data_mapper/support/inflector.rb +0 -265
  53. data/lib/data_mapper/support/object.rb +0 -54
  54. data/lib/data_mapper/support/serialization.rb +0 -96
  55. data/lib/data_mapper/support/silence.rb +0 -10
  56. data/lib/data_mapper/support/string.rb +0 -72
  57. data/lib/data_mapper/support/struct.rb +0 -7
  58. data/lib/data_mapper/support/symbol.rb +0 -82
  59. data/lib/data_mapper/support/typed_set.rb +0 -65
  60. data/lib/data_mapper/types/base.rb +0 -44
  61. data/lib/data_mapper/types/string.rb +0 -34
  62. data/lib/data_mapper/validatable_extensions/errors.rb +0 -12
  63. data/lib/data_mapper/validatable_extensions/macros.rb +0 -7
  64. data/lib/data_mapper/validatable_extensions/validatable_instance_methods.rb +0 -62
  65. data/lib/data_mapper/validatable_extensions/validation_base.rb +0 -18
  66. data/lib/data_mapper/validatable_extensions/validations/formats/email.rb +0 -43
  67. data/lib/data_mapper/validatable_extensions/validations/validates_acceptance_of.rb +0 -7
  68. data/lib/data_mapper/validatable_extensions/validations/validates_confirmation_of.rb +0 -7
  69. data/lib/data_mapper/validatable_extensions/validations/validates_each.rb +0 -7
  70. data/lib/data_mapper/validatable_extensions/validations/validates_format_of.rb +0 -28
  71. data/lib/data_mapper/validatable_extensions/validations/validates_length_of.rb +0 -15
  72. data/lib/data_mapper/validatable_extensions/validations/validates_numericality_of.rb +0 -7
  73. data/lib/data_mapper/validatable_extensions/validations/validates_presence_of.rb +0 -7
  74. data/lib/data_mapper/validatable_extensions/validations/validates_true_for.rb +0 -7
  75. data/lib/data_mapper/validatable_extensions/validations/validates_uniqueness_of.rb +0 -40
  76. data/lib/data_mapper/validations.rb +0 -20
  77. data/lib/data_mapper/validations/number_validator.rb +0 -40
  78. data/lib/data_mapper/validations/string_validator.rb +0 -20
  79. data/lib/data_mapper/validations/validator.rb +0 -13
  80. data/performance.rb +0 -307
  81. data/plugins/can_has_sphinx/LICENSE +0 -23
  82. data/plugins/can_has_sphinx/README +0 -4
  83. data/plugins/can_has_sphinx/REVISION +0 -1
  84. data/plugins/can_has_sphinx/Rakefile +0 -22
  85. data/plugins/can_has_sphinx/init.rb +0 -1
  86. data/plugins/can_has_sphinx/install.rb +0 -1
  87. data/plugins/can_has_sphinx/lib/acts_as_sphinx.rb +0 -123
  88. data/plugins/can_has_sphinx/lib/sphinx.rb +0 -460
  89. data/plugins/can_has_sphinx/scripts/sphinx.sh +0 -47
  90. data/plugins/can_has_sphinx/tasks/acts_as_sphinx_tasks.rake +0 -41
  91. data/profile_data_mapper.rb +0 -40
  92. data/rakefile.rb +0 -159
  93. data/spec/acts_as_tree_spec.rb +0 -67
  94. data/spec/adapters/data_object_adapter_spec.rb +0 -31
  95. data/spec/associations/belongs_to_association_spec.rb +0 -98
  96. data/spec/associations/has_and_belongs_to_many_association_spec.rb +0 -377
  97. data/spec/associations/has_many_association_spec.rb +0 -337
  98. data/spec/attributes_spec.rb +0 -52
  99. data/spec/auto_migrations_spec.rb +0 -101
  100. data/spec/callbacks_spec.rb +0 -186
  101. data/spec/can_has_sphinx.rb +0 -5
  102. data/spec/coersion_spec.rb +0 -41
  103. data/spec/column_spec.rb +0 -114
  104. data/spec/count_command_spec.rb +0 -45
  105. data/spec/database_spec.rb +0 -18
  106. data/spec/dataobjects_spec.rb +0 -27
  107. data/spec/delete_command_spec.rb +0 -11
  108. data/spec/dependency_spec.rb +0 -29
  109. data/spec/embedded_value_spec.rb +0 -161
  110. data/spec/fixtures/animals.yaml +0 -33
  111. data/spec/fixtures/animals_exhibits.yaml +0 -2
  112. data/spec/fixtures/careers.yaml +0 -5
  113. data/spec/fixtures/comments.yaml +0 -1
  114. data/spec/fixtures/exhibits.yaml +0 -90
  115. data/spec/fixtures/fruit.yaml +0 -6
  116. data/spec/fixtures/people.yaml +0 -37
  117. data/spec/fixtures/posts.yaml +0 -3
  118. data/spec/fixtures/projects.yaml +0 -13
  119. data/spec/fixtures/sections.yaml +0 -5
  120. data/spec/fixtures/serializers.yaml +0 -6
  121. data/spec/fixtures/tasks.yaml +0 -6
  122. data/spec/fixtures/tasks_tasks.yaml +0 -2
  123. data/spec/fixtures/tomatoes.yaml +0 -1
  124. data/spec/fixtures/users.yaml +0 -1
  125. data/spec/fixtures/zoos.yaml +0 -24
  126. data/spec/is_a_tree_spec.rb +0 -149
  127. data/spec/legacy_spec.rb +0 -16
  128. data/spec/load_command_spec.rb +0 -322
  129. data/spec/magic_columns_spec.rb +0 -26
  130. data/spec/migration_spec.rb +0 -267
  131. data/spec/mock_adapter.rb +0 -20
  132. data/spec/models/animal.rb +0 -12
  133. data/spec/models/candidate.rb +0 -8
  134. data/spec/models/career.rb +0 -7
  135. data/spec/models/chain.rb +0 -8
  136. data/spec/models/comment.rb +0 -6
  137. data/spec/models/exhibit.rb +0 -14
  138. data/spec/models/fence.rb +0 -7
  139. data/spec/models/fruit.rb +0 -8
  140. data/spec/models/job.rb +0 -8
  141. data/spec/models/person.rb +0 -30
  142. data/spec/models/post.rb +0 -14
  143. data/spec/models/project.rb +0 -41
  144. data/spec/models/sales_person.rb +0 -5
  145. data/spec/models/section.rb +0 -8
  146. data/spec/models/serializer.rb +0 -5
  147. data/spec/models/task.rb +0 -9
  148. data/spec/models/tomato.rb +0 -27
  149. data/spec/models/user.rb +0 -12
  150. data/spec/models/zoo.rb +0 -13
  151. data/spec/natural_key_spec.rb +0 -36
  152. data/spec/paranoia_spec.rb +0 -38
  153. data/spec/persistence_spec.rb +0 -479
  154. data/spec/postgres_spec.rb +0 -96
  155. data/spec/property_spec.rb +0 -151
  156. data/spec/query_spec.rb +0 -77
  157. data/spec/save_command_spec.rb +0 -94
  158. data/spec/schema_spec.rb +0 -8
  159. data/spec/serialize_spec.rb +0 -19
  160. data/spec/single_table_inheritance_spec.rb +0 -43
  161. data/spec/spec_helper.rb +0 -45
  162. data/spec/support/blank_spec.rb +0 -8
  163. data/spec/support/inflector_spec.rb +0 -41
  164. data/spec/support/object_spec.rb +0 -9
  165. data/spec/support/serialization_spec.rb +0 -61
  166. data/spec/support/silence_spec.rb +0 -15
  167. data/spec/support/string_spec.rb +0 -7
  168. data/spec/support/struct_spec.rb +0 -12
  169. data/spec/support/typed_set_spec.rb +0 -66
  170. data/spec/symbolic_operators_spec.rb +0 -27
  171. data/spec/table_spec.rb +0 -79
  172. data/spec/types/string.rb +0 -81
  173. data/spec/validates_confirmation_of_spec.rb +0 -55
  174. data/spec/validates_format_of_spec.rb +0 -78
  175. data/spec/validates_length_of_spec.rb +0 -117
  176. data/spec/validates_uniqueness_of_spec.rb +0 -92
  177. data/spec/validations/number_validator.rb +0 -59
  178. data/spec/validations/string_validator.rb +0 -14
  179. data/spec/validations_spec.rb +0 -141
  180. data/tasks/fixtures.rb +0 -53
@@ -1,26 +0,0 @@
1
- require File.dirname(__FILE__) + "/spec_helper"
2
-
3
- describe "Magic Columns" do
4
-
5
- it "should update updated_at on save" do
6
- zoo = Zoo.new(:name => 'Mary')
7
- zoo.save
8
- zoo.updated_at.should be_a_kind_of(Time)
9
- end
10
-
11
- it "should not update created_at when updating a model" do
12
- section = Section.create(:title => "Mars")
13
- old_created_at = section.created_at
14
- section.update_attributes(:title => "Mars2!")
15
- section.created_at.should eql(old_created_at)
16
- end
17
-
18
- it "should not set the created_at/on fields if already set on creation" do
19
- section = Section.new(:title => "Mars")
20
- fixed_created_at = Time::now - 2600
21
- section.created_at = fixed_created_at
22
- section.save
23
- section.created_at.should eql(fixed_created_at)
24
- end
25
-
26
- end
@@ -1,267 +0,0 @@
1
- require File.dirname(__FILE__) + "/spec_helper"
2
- require File.dirname(__FILE__) + "/../lib/data_mapper/migration"
3
-
4
- class MigrationUser
5
- include DataMapper::Persistence
6
-
7
- property :name, :string
8
- property :login, :string
9
-
10
- end
11
-
12
- def check_schema
13
- case ENV['ADAPTER']
14
- when 'postgresql'
15
- result = database.query("
16
- SELECT table_name, column_name FROM information_schema.columns WHERE table_name = 'migration_users'
17
- ").join(", ")
18
- result.blank? ? nil : result
19
- when 'mysql'
20
- begin
21
- database.query("SHOW CREATE TABLE migration_users")[0]["create table"]
22
- rescue Exception => e
23
- raise e unless e.message.match(/Table.*doesn\'t exist/)
24
- end
25
- else
26
- database.query("
27
- SELECT sql FROM
28
- (SELECT * FROM sqlite_master UNION ALL
29
- SELECT * FROM sqlite_temp_master)
30
- WHERE name = 'migration_users'
31
- ORDER BY substr(type,2,1), name
32
- ")[0]
33
- end
34
- end
35
-
36
- describe DataMapper::Migration do
37
-
38
- class AddUsers < DataMapper::Migration
39
- def self.up
40
- table :migration_users do # sees that the users table does not exist and so creates the table
41
- add :name, :string
42
- add :login, :string
43
- end
44
- end
45
-
46
- def self.down
47
- table.drop :migration_users
48
- end
49
- end
50
-
51
- class AddPasswordToUsers < DataMapper::Migration
52
- def self.up
53
- table :migration_users do
54
- add :password, :string
55
- end
56
- end
57
-
58
- def self.down
59
- table :migration_users do
60
- remove :password
61
- end
62
- end
63
- end
64
-
65
- class RenameLoginOnUsers < DataMapper::Migration
66
- def self.up
67
- table :migration_users do
68
- rename :login, :username
69
- end
70
- end
71
-
72
- def self.down
73
- table :migration_users do
74
- rename :username, :login
75
- end
76
- end
77
- end
78
-
79
- class AlterLoginOnUsers < DataMapper::Migration
80
- def self.up
81
- table :migration_users do
82
- alter :login, :text, :nullable => false, :default => "username"
83
- end
84
- end
85
-
86
- def self.down
87
- table :migration_users do
88
- alter :login, :string
89
- end
90
- end
91
- end
92
-
93
- it "should migrate up creating a table with its columns" do
94
- AddUsers.migrate(:up)
95
- database.table_exists?(MigrationUser).should be_true
96
- check_schema.should match(/migration_users/)
97
- check_schema.should match(/name|login/)
98
- user = MigrationUser.new(:name => "test", :login => "username")
99
- user.save.should be_true
100
- MigrationUser.first.should == user
101
- end
102
-
103
- it "should migrate down deleting the created table" do
104
- AddUsers.migrate(:down)
105
- check_schema.should be_nil
106
- database.table_exists?(MigrationUser).should == false
107
- end
108
-
109
- it "should migrate up altering a table to add a column" do
110
- AddUsers.migrate(:up)
111
- AddPasswordToUsers.migrate(:up)
112
- table = database.table(MigrationUser)
113
- table[:password].should_not be_nil
114
- end
115
-
116
- it "should migrate down altering a table to remove a column" do
117
- check_schema.should match(/password/)
118
- AddPasswordToUsers.migrate(:down)
119
- check_schema.should_not match(/password/)
120
- table = database.table(MigrationUser)
121
- table[:password].should be_nil
122
- AddUsers.migrate(:down)
123
- end
124
-
125
- it "should migrate up renaming a column" do
126
- AddUsers.migrate(:up)
127
- user = MigrationUser.create(:name => "Sam", :login => "sammy")
128
- RenameLoginOnUsers.migrate(:up)
129
- class MigrationUser
130
- property :username, :string
131
- end
132
- check_schema.should match(/username/)
133
- check_schema.should_not match(/login/)
134
- MigrationUser.first.username.should == user.login
135
- end
136
-
137
- it "should migrate down renaming a column" do
138
- user = MigrationUser.first
139
- RenameLoginOnUsers.migrate(:down)
140
- check_schema.should_not match(/username/)
141
- check_schema.should match(/login/)
142
- MigrationUser.first.login.should == user.username
143
- AddUsers.migrate(:down)
144
- end
145
-
146
- it "should migrate up altering a column" do
147
- AddUsers.migrate(:up)
148
- AlterLoginOnUsers.migrate(:up)
149
- column = database.table(MigrationUser)[:login]
150
- column.type.should == :text
151
- column.nullable?.should be_false
152
- column.default.should == "username"
153
- end
154
-
155
- it "should migrate down altering a column" do
156
- AlterLoginOnUsers.migrate(:down)
157
- column = database.table(MigrationUser)[:login]
158
- column.type.should == :string
159
- column.nullable?.should be_true
160
- column.default.should be_nil
161
- AddUsers.migrate(:down)
162
- end
163
- end
164
-
165
- describe "DataMapper::Migration [RAILS]" do
166
- class RailsAddUsers < DataMapper::Migration
167
- def self.up
168
- create_table :migration_users do |t|
169
- t.column :name, :string
170
- t.column :login, :string
171
- end
172
- end
173
-
174
- def self.down
175
- drop_table :migration_users
176
- end
177
- end
178
-
179
- class RailsAddPasswordToUsers < DataMapper::Migration
180
- def self.up
181
- add_column :migration_users, :password, :string
182
- end
183
-
184
- def self.down
185
- remove_column :migration_users, :password
186
- end
187
- end
188
-
189
- class RailsRenameLoginOnUsers < DataMapper::Migration
190
- def self.up
191
- rename_column :migration_users, :login, :username
192
- end
193
-
194
- def self.down
195
- rename_column :migration_users, :username, :login
196
- end
197
- end
198
-
199
- class RailsAlterLoginOnUsers < DataMapper::Migration
200
- def self.up
201
- change_column :migration_users, :login, :text, :nullable => false, :default => "username"
202
- end
203
-
204
- def self.down
205
- change_column :migration_users, :login, :string
206
- end
207
- end
208
-
209
- it "should migrate up creating a table with its columns" do
210
- RailsAddUsers.migrate(:up)
211
- database.table_exists?(MigrationUser).should be_true
212
- check_schema.should match(/migration_users/)
213
- check_schema.should match(/name|login/)
214
- end
215
-
216
- it "should migrate down deleting the created table" do
217
- RailsAddUsers.migrate(:down)
218
- database.table_exists?(MigrationUser).should be_false
219
- check_schema.should be_nil
220
- end
221
-
222
- it "should migrate up altering a table to add a column" do
223
- RailsAddUsers.migrate(:up)
224
- RailsAddPasswordToUsers.migrate(:up)
225
- check_schema.should match(/password/)
226
- end
227
-
228
- it "should migrate down altering a table to remove a column" do
229
- RailsAddPasswordToUsers.migrate(:down)
230
- check_schema.should_not match(/password/)
231
- table = database.table(MigrationUser)
232
- table[:password].should be_nil
233
- RailsAddUsers.migrate(:down)
234
- end
235
-
236
- it "should migrate up renaming a column" do
237
- RailsAddUsers.migrate(:up)
238
- RailsRenameLoginOnUsers.migrate(:up)
239
- check_schema.should match(/username/)
240
- check_schema.should_not match(/login/)
241
- end
242
-
243
- it "should migrate down renaming a column" do
244
- RailsRenameLoginOnUsers.migrate(:down)
245
- check_schema.should match(/login/)
246
- check_schema.should_not match(/username/)
247
- RailsAddUsers.migrate(:down)
248
- end
249
-
250
- it "should migrate up altering a column" do
251
- AddUsers.migrate(:up)
252
- RailsAlterLoginOnUsers.migrate(:up)
253
- column = database.table(MigrationUser)[:login]
254
- column.type.should == :text
255
- column.nullable?.should be_false
256
- column.default.should == "username"
257
- end
258
-
259
- it "should migrate down altering a column" do
260
- RailsAlterLoginOnUsers.migrate(:down)
261
- column = database.table(MigrationUser)[:login]
262
- column.type.should == :string
263
- column.nullable?.should be_true
264
- column.default.should be_nil
265
- AddUsers.migrate(:down)
266
- end
267
- end
@@ -1,20 +0,0 @@
1
- require 'data_mapper/adapters/data_object_adapter'
2
-
3
- class MockAdapter < DataMapper::Adapters::DataObjectAdapter
4
- COLUMN_QUOTING_CHARACTER = "`"
5
- TABLE_QUOTING_CHARACTER = "`"
6
-
7
- def delete(instance_or_klass, options = nil)
8
- end
9
-
10
- def save(database_context, instance)
11
- end
12
-
13
- def load(database_context, klass, options)
14
- end
15
-
16
- def table_exists?(name)
17
- true
18
- end
19
-
20
- end
@@ -1,12 +0,0 @@
1
- class Animal #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- property :name, :string, :default => "No Name", :index => :unique
5
- property :notes, :text
6
- property :nice, :boolean
7
-
8
- has_one :favourite_fruit, :class => 'Fruit', :foreign_key => 'devourer_id'
9
- has_and_belongs_to_many :exhibits
10
-
11
- DEFAULT_LIMIT = 5
12
- end
@@ -1,8 +0,0 @@
1
- class Candidate #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- property :name, :string
5
-
6
- belongs_to :job
7
- has_and_belongs_to_many :applications, :class => 'Job', :join_table => "applications_candidates"
8
- end
@@ -1,7 +0,0 @@
1
- class Career #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- property :name, :string, :key => true
5
-
6
- has_many :followers, :class => 'Person'
7
- end
@@ -1,8 +0,0 @@
1
- class Chain #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- property :name, :string
5
-
6
- belongs_to :fence
7
- #has_and_belongs_to_many :chains # do not remove this
8
- end
@@ -1,6 +0,0 @@
1
- class Comment #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- property :comment, :text, :lazy => false
5
- belongs_to :author, :class => 'User', :foreign_key => 'user_id'
6
- end
@@ -1,14 +0,0 @@
1
- class Exhibit #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- property :name, :string
5
-
6
- begin
7
- validates_presence_of :name
8
- rescue ArgumentError => e
9
- throw e unless e.message =~ /specify a unique key/
10
- end
11
-
12
- belongs_to :zoo
13
- has_and_belongs_to_many :animals
14
- end
@@ -1,7 +0,0 @@
1
- class Fence #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- property :name, :string
5
-
6
- #has_many :chains # do not remove
7
- end
@@ -1,8 +0,0 @@
1
- class Fruit #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- set_table_name 'fruit'
5
- property :name, :string, :column => 'fruit_name'
6
-
7
- belongs_to :devourer_of_souls, :class => 'Animal', :foreign_key => 'devourer_id'
8
- end
@@ -1,8 +0,0 @@
1
- class Job #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- property :name, :string
5
- property :hours, :days, :integer, :default => 0
6
-
7
- has_and_belongs_to_many :candidates, :join_table => "applications_candidates"
8
- end
@@ -1,30 +0,0 @@
1
- class Person #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- property [:name, :occupation], :string
5
- property :age, :integer
6
- property :type, :class
7
- property :notes, :text
8
- property :date_of_birth, :date
9
-
10
- embed :address, :prefix => true do
11
- property :street, :string
12
- property :city, :string
13
- property :state, :string, :size => 2
14
- property :zip_code, :string, :size => 10
15
-
16
- def city_state_zip_code
17
- "#{city}, #{state} #{zip_code}"
18
- end
19
-
20
- end
21
-
22
- belongs_to :career
23
-
24
- before_save :before_save_callback
25
-
26
- def before_save_callback
27
- @notes = "Lorem ipsum dolor sit amet"
28
- end
29
-
30
- end
@@ -1,14 +0,0 @@
1
- class Post #< DataMapper::Base # please do not remove this
2
- include DataMapper::Persistence
3
-
4
- property :title, :string
5
- property :created_at, :datetime
6
-
7
- def next
8
- Post.first(:created_at.gte => self.created_at, :id.gt => self.id, :order => "created_at, id")
9
- end
10
-
11
- def previous
12
- Post.first(:created_at.lte => self.created_at, :id.lt => self.id, :order => "created_at DESC, id DESC")
13
- end
14
- end