datamapper 0.3.2 → 0.9.3
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.
- data/History.txt +0 -0
- data/Manifest.txt +5 -0
- data/README.txt +11 -0
- data/Rakefile +70 -0
- data/lib/datamapper.rb +8 -0
- metadata +152 -319
- data/CHANGELOG +0 -145
- data/FAQ +0 -96
- data/MIT-LICENSE +0 -22
- data/QUICKLINKS +0 -12
- data/README +0 -105
- data/environment.rb +0 -62
- data/example.rb +0 -156
- data/lib/data_mapper.rb +0 -88
- data/lib/data_mapper/adapters/abstract_adapter.rb +0 -43
- data/lib/data_mapper/adapters/data_object_adapter.rb +0 -480
- data/lib/data_mapper/adapters/mysql_adapter.rb +0 -72
- data/lib/data_mapper/adapters/postgresql_adapter.rb +0 -258
- data/lib/data_mapper/adapters/sql/coersion.rb +0 -134
- data/lib/data_mapper/adapters/sql/commands/load_command.rb +0 -545
- data/lib/data_mapper/adapters/sql/mappings/associations_set.rb +0 -34
- data/lib/data_mapper/adapters/sql/mappings/column.rb +0 -279
- data/lib/data_mapper/adapters/sql/mappings/conditions.rb +0 -172
- data/lib/data_mapper/adapters/sql/mappings/schema.rb +0 -60
- data/lib/data_mapper/adapters/sql/mappings/table.rb +0 -459
- data/lib/data_mapper/adapters/sql/quoting.rb +0 -24
- data/lib/data_mapper/adapters/sqlite3_adapter.rb +0 -159
- data/lib/data_mapper/associations.rb +0 -106
- data/lib/data_mapper/associations/belongs_to_association.rb +0 -160
- data/lib/data_mapper/associations/has_and_belongs_to_many_association.rb +0 -437
- data/lib/data_mapper/associations/has_many_association.rb +0 -283
- data/lib/data_mapper/associations/has_n_association.rb +0 -143
- data/lib/data_mapper/associations/reference.rb +0 -47
- data/lib/data_mapper/attributes.rb +0 -73
- data/lib/data_mapper/auto_migrations.rb +0 -36
- data/lib/data_mapper/base.rb +0 -17
- data/lib/data_mapper/callbacks.rb +0 -107
- data/lib/data_mapper/context.rb +0 -112
- data/lib/data_mapper/database.rb +0 -234
- data/lib/data_mapper/dependency_queue.rb +0 -28
- data/lib/data_mapper/embedded_value.rb +0 -145
- data/lib/data_mapper/identity_map.rb +0 -47
- data/lib/data_mapper/is/tree.rb +0 -121
- data/lib/data_mapper/migration.rb +0 -155
- data/lib/data_mapper/persistence.rb +0 -852
- data/lib/data_mapper/property.rb +0 -310
- data/lib/data_mapper/query.rb +0 -164
- data/lib/data_mapper/support/blank.rb +0 -35
- data/lib/data_mapper/support/connection_pool.rb +0 -117
- data/lib/data_mapper/support/enumerable.rb +0 -35
- data/lib/data_mapper/support/errors.rb +0 -16
- data/lib/data_mapper/support/inflector.rb +0 -265
- data/lib/data_mapper/support/object.rb +0 -54
- data/lib/data_mapper/support/serialization.rb +0 -96
- data/lib/data_mapper/support/silence.rb +0 -10
- data/lib/data_mapper/support/string.rb +0 -72
- data/lib/data_mapper/support/struct.rb +0 -7
- data/lib/data_mapper/support/symbol.rb +0 -82
- data/lib/data_mapper/support/typed_set.rb +0 -65
- data/lib/data_mapper/types/base.rb +0 -44
- data/lib/data_mapper/types/string.rb +0 -34
- data/lib/data_mapper/validatable_extensions/errors.rb +0 -12
- data/lib/data_mapper/validatable_extensions/macros.rb +0 -7
- data/lib/data_mapper/validatable_extensions/validatable_instance_methods.rb +0 -62
- data/lib/data_mapper/validatable_extensions/validation_base.rb +0 -18
- data/lib/data_mapper/validatable_extensions/validations/formats/email.rb +0 -43
- data/lib/data_mapper/validatable_extensions/validations/validates_acceptance_of.rb +0 -7
- data/lib/data_mapper/validatable_extensions/validations/validates_confirmation_of.rb +0 -7
- data/lib/data_mapper/validatable_extensions/validations/validates_each.rb +0 -7
- data/lib/data_mapper/validatable_extensions/validations/validates_format_of.rb +0 -28
- data/lib/data_mapper/validatable_extensions/validations/validates_length_of.rb +0 -15
- data/lib/data_mapper/validatable_extensions/validations/validates_numericality_of.rb +0 -7
- data/lib/data_mapper/validatable_extensions/validations/validates_presence_of.rb +0 -7
- data/lib/data_mapper/validatable_extensions/validations/validates_true_for.rb +0 -7
- data/lib/data_mapper/validatable_extensions/validations/validates_uniqueness_of.rb +0 -40
- data/lib/data_mapper/validations.rb +0 -20
- data/lib/data_mapper/validations/number_validator.rb +0 -40
- data/lib/data_mapper/validations/string_validator.rb +0 -20
- data/lib/data_mapper/validations/validator.rb +0 -13
- data/performance.rb +0 -307
- data/plugins/can_has_sphinx/LICENSE +0 -23
- data/plugins/can_has_sphinx/README +0 -4
- data/plugins/can_has_sphinx/REVISION +0 -1
- data/plugins/can_has_sphinx/Rakefile +0 -22
- data/plugins/can_has_sphinx/init.rb +0 -1
- data/plugins/can_has_sphinx/install.rb +0 -1
- data/plugins/can_has_sphinx/lib/acts_as_sphinx.rb +0 -123
- data/plugins/can_has_sphinx/lib/sphinx.rb +0 -460
- data/plugins/can_has_sphinx/scripts/sphinx.sh +0 -47
- data/plugins/can_has_sphinx/tasks/acts_as_sphinx_tasks.rake +0 -41
- data/profile_data_mapper.rb +0 -40
- data/rakefile.rb +0 -159
- data/spec/acts_as_tree_spec.rb +0 -67
- data/spec/adapters/data_object_adapter_spec.rb +0 -31
- data/spec/associations/belongs_to_association_spec.rb +0 -98
- data/spec/associations/has_and_belongs_to_many_association_spec.rb +0 -377
- data/spec/associations/has_many_association_spec.rb +0 -337
- data/spec/attributes_spec.rb +0 -52
- data/spec/auto_migrations_spec.rb +0 -101
- data/spec/callbacks_spec.rb +0 -186
- data/spec/can_has_sphinx.rb +0 -5
- data/spec/coersion_spec.rb +0 -41
- data/spec/column_spec.rb +0 -114
- data/spec/count_command_spec.rb +0 -45
- data/spec/database_spec.rb +0 -18
- data/spec/dataobjects_spec.rb +0 -27
- data/spec/delete_command_spec.rb +0 -11
- data/spec/dependency_spec.rb +0 -29
- data/spec/embedded_value_spec.rb +0 -161
- data/spec/fixtures/animals.yaml +0 -33
- data/spec/fixtures/animals_exhibits.yaml +0 -2
- data/spec/fixtures/careers.yaml +0 -5
- data/spec/fixtures/comments.yaml +0 -1
- data/spec/fixtures/exhibits.yaml +0 -90
- data/spec/fixtures/fruit.yaml +0 -6
- data/spec/fixtures/people.yaml +0 -37
- data/spec/fixtures/posts.yaml +0 -3
- data/spec/fixtures/projects.yaml +0 -13
- data/spec/fixtures/sections.yaml +0 -5
- data/spec/fixtures/serializers.yaml +0 -6
- data/spec/fixtures/tasks.yaml +0 -6
- data/spec/fixtures/tasks_tasks.yaml +0 -2
- data/spec/fixtures/tomatoes.yaml +0 -1
- data/spec/fixtures/users.yaml +0 -1
- data/spec/fixtures/zoos.yaml +0 -24
- data/spec/is_a_tree_spec.rb +0 -149
- data/spec/legacy_spec.rb +0 -16
- data/spec/load_command_spec.rb +0 -322
- data/spec/magic_columns_spec.rb +0 -26
- data/spec/migration_spec.rb +0 -267
- data/spec/mock_adapter.rb +0 -20
- data/spec/models/animal.rb +0 -12
- data/spec/models/candidate.rb +0 -8
- data/spec/models/career.rb +0 -7
- data/spec/models/chain.rb +0 -8
- data/spec/models/comment.rb +0 -6
- data/spec/models/exhibit.rb +0 -14
- data/spec/models/fence.rb +0 -7
- data/spec/models/fruit.rb +0 -8
- data/spec/models/job.rb +0 -8
- data/spec/models/person.rb +0 -30
- data/spec/models/post.rb +0 -14
- data/spec/models/project.rb +0 -41
- data/spec/models/sales_person.rb +0 -5
- data/spec/models/section.rb +0 -8
- data/spec/models/serializer.rb +0 -5
- data/spec/models/task.rb +0 -9
- data/spec/models/tomato.rb +0 -27
- data/spec/models/user.rb +0 -12
- data/spec/models/zoo.rb +0 -13
- data/spec/natural_key_spec.rb +0 -36
- data/spec/paranoia_spec.rb +0 -38
- data/spec/persistence_spec.rb +0 -479
- data/spec/postgres_spec.rb +0 -96
- data/spec/property_spec.rb +0 -151
- data/spec/query_spec.rb +0 -77
- data/spec/save_command_spec.rb +0 -94
- data/spec/schema_spec.rb +0 -8
- data/spec/serialize_spec.rb +0 -19
- data/spec/single_table_inheritance_spec.rb +0 -43
- data/spec/spec_helper.rb +0 -45
- data/spec/support/blank_spec.rb +0 -8
- data/spec/support/inflector_spec.rb +0 -41
- data/spec/support/object_spec.rb +0 -9
- data/spec/support/serialization_spec.rb +0 -61
- data/spec/support/silence_spec.rb +0 -15
- data/spec/support/string_spec.rb +0 -7
- data/spec/support/struct_spec.rb +0 -12
- data/spec/support/typed_set_spec.rb +0 -66
- data/spec/symbolic_operators_spec.rb +0 -27
- data/spec/table_spec.rb +0 -79
- data/spec/types/string.rb +0 -81
- data/spec/validates_confirmation_of_spec.rb +0 -55
- data/spec/validates_format_of_spec.rb +0 -78
- data/spec/validates_length_of_spec.rb +0 -117
- data/spec/validates_uniqueness_of_spec.rb +0 -92
- data/spec/validations/number_validator.rb +0 -59
- data/spec/validations/string_validator.rb +0 -14
- data/spec/validations_spec.rb +0 -141
- data/tasks/fixtures.rb +0 -53
data/spec/count_command_spec.rb
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
|
2
|
-
|
|
3
|
-
describe DataMapper::Adapters::AbstractAdapter, "count()" do
|
|
4
|
-
|
|
5
|
-
before(:all) do
|
|
6
|
-
fixtures(:zoos)
|
|
7
|
-
fixtures(:projects)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "should return a count of the selected table" do
|
|
11
|
-
Zoo.count.should be_a_kind_of(Integer)
|
|
12
|
-
Zoo.count.should == Zoo.all.size
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "should accept finder style options" do
|
|
16
|
-
# Hash-style (with SymbolOperators)
|
|
17
|
-
Zoo.count(:name => 'Dallas').should == Zoo.all(:name => 'Dallas').length
|
|
18
|
-
Zoo.count(:name.not => nil).should == Zoo.all(:name.not => nil).length
|
|
19
|
-
Zoo.count(:name.not => nil, :notes => nil).should == Zoo.all(:name.not => nil, :notes => nil).length
|
|
20
|
-
Zoo.count(:name.like => '%.%').should == Zoo.all(:name.like => '%.%').length
|
|
21
|
-
|
|
22
|
-
# :conditions
|
|
23
|
-
Zoo.count(:conditions => ["name = ?", 'Dallas']).should == Zoo.all(:conditions => ["name = ?", 'Dallas']).length
|
|
24
|
-
|
|
25
|
-
# mix and match
|
|
26
|
-
Zoo.count(:notes => nil, :conditions => ["name = ?", 'Dallas']).should == Zoo.all(:notes => nil, :conditions => ["name = ?", 'Dallas']).length
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should respect paranoia" do
|
|
30
|
-
p = Project[3]
|
|
31
|
-
p.destroy!
|
|
32
|
-
|
|
33
|
-
Project.count.should == Project.all.length
|
|
34
|
-
# clean up
|
|
35
|
-
p.deleted_at = nil
|
|
36
|
-
p.save
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
#This won't work at the moment, hopefully before 0.3.0
|
|
40
|
-
it "should do distinct counting" do
|
|
41
|
-
#Zoo.count(:distinct => :name).should == Zoo.all.length # there all distinct in the fixtures
|
|
42
|
-
#Zoo.count(:distinct => :name, :notes.not => nil).should == Zoo.all(:notes.not => nil).length
|
|
43
|
-
#Zoo.count(:distinct => :name, :conditions => ["notes is not null"]).should == Zoo.all(:notes.not => nil).length
|
|
44
|
-
end
|
|
45
|
-
end
|
data/spec/database_spec.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
|
2
|
-
|
|
3
|
-
describe('Multiple Databases') do
|
|
4
|
-
|
|
5
|
-
it "should scope model creation and lookup" do
|
|
6
|
-
database(:secondary) do
|
|
7
|
-
Zoo.create :name => 'secondary'
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
Zoo.first(:name => 'secondary').should be_nil
|
|
11
|
-
|
|
12
|
-
database(:secondary) do
|
|
13
|
-
Zoo.first(:name => 'secondary').should_not be_nil
|
|
14
|
-
Zoo.first(:name => 'secondary').destroy!
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
end
|
data/spec/dataobjects_spec.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
|
2
|
-
|
|
3
|
-
describe DataObject do
|
|
4
|
-
|
|
5
|
-
# These specs only fail in MySQL because:
|
|
6
|
-
# 1) An insert happened in the previous connection
|
|
7
|
-
# 2) We are searching for NULL
|
|
8
|
-
#
|
|
9
|
-
# It turns out that this is actually by design o.O:
|
|
10
|
-
# http://dev.mysql.com/doc/refman/5.0/en/myodbc-usagenotes-functionality.html
|
|
11
|
-
#
|
|
12
|
-
# Certain ODBC applications (including Delphi and Access) may have trouble
|
|
13
|
-
# obtaining the auto-increment value using the previous examples. In this case,
|
|
14
|
-
# try the following statement as an alternative:
|
|
15
|
-
# SELECT * FROM tbl WHERE auto IS NULL;
|
|
16
|
-
it "should return an empty reader" do
|
|
17
|
-
database.adapter.connection do |connection|
|
|
18
|
-
sql = 'SELECT `id`, `name` FROM `zoos` WHERE (`id` IS NULL)'.gsub(/\`/, database.adapter.class::COLUMN_QUOTING_CHARACTER)
|
|
19
|
-
command = connection.create_command(sql)
|
|
20
|
-
|
|
21
|
-
command.execute_reader do |reader|
|
|
22
|
-
reader.has_rows?.should eql(ENV['ADAPTER'] == 'mysql')
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
data/spec/delete_command_spec.rb
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
|
2
|
-
|
|
3
|
-
describe "Delete Command" do
|
|
4
|
-
|
|
5
|
-
it "should drop and create the table" do
|
|
6
|
-
database.schema[Zoo].drop!.should == true
|
|
7
|
-
database.schema[Zoo].exists?.should == false
|
|
8
|
-
database.schema[Zoo].create!.should == true
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
end
|
data/spec/dependency_spec.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
|
2
|
-
|
|
3
|
-
# Can't describe DataMapper::Persistence because
|
|
4
|
-
# rspec will include it for some crazy reason!
|
|
5
|
-
describe "DataMapper::Persistence" do
|
|
6
|
-
|
|
7
|
-
it "should be able to add a dependency for a class not yet defined" do
|
|
8
|
-
|
|
9
|
-
$happy_cow_defined = false
|
|
10
|
-
|
|
11
|
-
DataMapper::Persistence.dependencies.add('HappyCow') do |klass|
|
|
12
|
-
klass.should eql(Object.const_get('HappyCow'))
|
|
13
|
-
database.table(klass).key.name.should eql(:name)
|
|
14
|
-
$happy_cow_defined = true
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
class HappyCow #< DataMapper::Base # please do not remove this
|
|
18
|
-
include DataMapper::Persistence
|
|
19
|
-
|
|
20
|
-
property :name, :string, :key => true
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Dependencies are not resolved until you try to access the key for a table...
|
|
24
|
-
database.table(HappyCow).key
|
|
25
|
-
|
|
26
|
-
raise 'Dependency not called for HappyCow :-(' unless $happy_cow_defined
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
data/spec/embedded_value_spec.rb
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
|
2
|
-
|
|
3
|
-
describe DataMapper::EmbeddedValue do
|
|
4
|
-
|
|
5
|
-
before(:all) do
|
|
6
|
-
@bob = Person.first(:name => 'Bob')
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it 'should proxy getting values for you' do
|
|
10
|
-
@bob.address.street.should == '123 Happy Ln.'
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'should return a sub-class of the containing class' do
|
|
14
|
-
@bob.address.class.should be(Person::Address)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'should allow definition of instance methods' do
|
|
18
|
-
@bob.address.city_state_zip_code.should == 'Dallas, TX 75000'
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'should not require prefix' do
|
|
22
|
-
class PointyHeadedBoss #< DataMapper::Base # please do not remove this
|
|
23
|
-
include DataMapper::Persistence
|
|
24
|
-
|
|
25
|
-
set_table_name 'people'
|
|
26
|
-
property :name, :string
|
|
27
|
-
|
|
28
|
-
embed :address do
|
|
29
|
-
# don't provide a prefix option to embed
|
|
30
|
-
# so the column names of these properties gets nothing auto-prepended
|
|
31
|
-
property :address_street, :string
|
|
32
|
-
property :address_city, :string
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
@sam = PointyHeadedBoss.first(:name => 'Sam')
|
|
37
|
-
@sam.address.address_street.should == '1337 Duck Way'
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'should add convenience methods to the non-embedded base' do
|
|
41
|
-
class Employee #< DataMapper::Base # please do not remove this
|
|
42
|
-
include DataMapper::Persistence
|
|
43
|
-
|
|
44
|
-
set_table_name 'people'
|
|
45
|
-
property :name, :string
|
|
46
|
-
|
|
47
|
-
embed :address, :prefix => true do
|
|
48
|
-
property :street, :string
|
|
49
|
-
property :city, :string
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
@sam = Employee.first(:name => 'Sam')
|
|
54
|
-
@sam.address_street.should == '1337 Duck Way'
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'should support lazy loading of embedded properties' do
|
|
58
|
-
class Human #< DataMapper::Base # please do not remove this
|
|
59
|
-
include DataMapper::Persistence
|
|
60
|
-
|
|
61
|
-
set_table_name 'people'
|
|
62
|
-
property :name, :string
|
|
63
|
-
|
|
64
|
-
embed :address, :lazy => true, :prefix => true do
|
|
65
|
-
property :street, :string
|
|
66
|
-
property :city, :string
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
@sam = Human.first(:name => 'Sam')
|
|
71
|
-
@sam.address.street.should == '1337 Duck Way'
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it 'should default to public method visibility for all' do
|
|
75
|
-
class SoftwareEngineer #< DataMapper::Base # please do not remove this
|
|
76
|
-
include DataMapper::Persistence
|
|
77
|
-
|
|
78
|
-
set_table_name 'people'
|
|
79
|
-
property :name, :string
|
|
80
|
-
|
|
81
|
-
embed :address, :prefix => true do
|
|
82
|
-
property :city, :string
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
@sam = SoftwareEngineer.first(:name => 'Sam')
|
|
87
|
-
public_properties = @sam.address.class.public_instance_methods.select { |m| ["city", "city="].include?(m) }
|
|
88
|
-
public_properties.length.should == 2
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it 'should respect protected property options for all' do
|
|
92
|
-
class SanitationEngineer #< DataMapper::Base # please do not remove this
|
|
93
|
-
include DataMapper::Persistence
|
|
94
|
-
|
|
95
|
-
set_table_name 'people'
|
|
96
|
-
property :name, :string
|
|
97
|
-
|
|
98
|
-
embed :address, :reader => :protected, :prefix => true do
|
|
99
|
-
property :city, :string
|
|
100
|
-
property :street, :string
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
@sam = SanitationEngineer.first(:name => 'Sam')
|
|
105
|
-
protected_properties = @sam.address.class.protected_instance_methods.select { |m| ["city", "street"].include?(m) }
|
|
106
|
-
protected_properties.length.should == 2
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
it 'should respect private property options for all' do
|
|
110
|
-
class ElectricalEngineer #< DataMapper::Base # please do not remove this
|
|
111
|
-
include DataMapper::Persistence
|
|
112
|
-
|
|
113
|
-
set_table_name 'people'
|
|
114
|
-
property :name, :string, :reader => :private
|
|
115
|
-
|
|
116
|
-
embed :address, :writer => :private, :prefix => true do
|
|
117
|
-
property :city, :string
|
|
118
|
-
property :street, :string
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
@sam = ElectricalEngineer.first(:name => 'Sam')
|
|
123
|
-
private_properties = @sam.address.class.private_instance_methods.select { |m| ["city=", "street="].include?(m) }
|
|
124
|
-
private_properties.length.should == 2
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it 'should set both reader and writer visibiliy for all when accessor option is passed' do
|
|
128
|
-
class TrainEngineer #< DataMapper::Base # please do not remove this
|
|
129
|
-
include DataMapper::Persistence
|
|
130
|
-
|
|
131
|
-
set_table_name 'people'
|
|
132
|
-
property :name, :string, :reader => :private
|
|
133
|
-
|
|
134
|
-
embed :address, :accessor => :private, :prefix => true do
|
|
135
|
-
property :city, :string
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
@sam = TrainEngineer.first(:name => 'Sam')
|
|
140
|
-
private_properties = @sam.address.class.private_instance_methods.select { |m| ["city", "city="].include?(m) }
|
|
141
|
-
private_properties.length.should == 2
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it 'should allow individual properties to override method visibility options passed on the block' do
|
|
145
|
-
class ChemicalEngineer #< DataMapper::Base # please do not remove this
|
|
146
|
-
include DataMapper::Persistence
|
|
147
|
-
|
|
148
|
-
set_table_name 'people'
|
|
149
|
-
property :name, :string
|
|
150
|
-
|
|
151
|
-
embed :address, :accessor => :private, :prefix => true do
|
|
152
|
-
property :city, :string
|
|
153
|
-
property :street, :string, :accessor => :public
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
@sam = ChemicalEngineer.first(:name => 'Sam')
|
|
158
|
-
public_properties = @sam.address.class.public_instance_methods.select { |m| ["street", "street="].include?(m) }
|
|
159
|
-
public_properties.length.should == 2
|
|
160
|
-
end
|
|
161
|
-
end
|
data/spec/fixtures/animals.yaml
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
- name: Frog
|
|
2
|
-
notes: I am a Frog!
|
|
3
|
-
- name: Bear
|
|
4
|
-
notes: I am a Bear!
|
|
5
|
-
- name: Giraffe
|
|
6
|
-
notes: I am a Giraffe!
|
|
7
|
-
- name: Zebra
|
|
8
|
-
notes: I am a Zebra!
|
|
9
|
-
- name: Cow
|
|
10
|
-
notes: I am a Cow!
|
|
11
|
-
- name: Pig
|
|
12
|
-
notes: I am a Pig!
|
|
13
|
-
- name: Cup
|
|
14
|
-
notes: I am a Cup!
|
|
15
|
-
- name: Cat
|
|
16
|
-
notes: I am a Cat!
|
|
17
|
-
- name: Dog
|
|
18
|
-
notes: I am a Dog!
|
|
19
|
-
- name: Elephant
|
|
20
|
-
notes: I am a Elephant!
|
|
21
|
-
- name: Whale
|
|
22
|
-
notes: I am a Whale!
|
|
23
|
-
- name: Dolphin
|
|
24
|
-
notes: I am a Dolphin!
|
|
25
|
-
nice: true
|
|
26
|
-
- name: Mouse
|
|
27
|
-
notes: I am a Mouse!
|
|
28
|
-
- name: Rat
|
|
29
|
-
notes: I am a Rat!
|
|
30
|
-
- name: Camel
|
|
31
|
-
notes: I am a Camel!
|
|
32
|
-
- name: Fox
|
|
33
|
-
notes: I am a Fox!
|
data/spec/fixtures/careers.yaml
DELETED
data/spec/fixtures/comments.yaml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--- []
|
data/spec/fixtures/exhibits.yaml
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
- name: Horses & Courses
|
|
2
|
-
zoo_id: 1
|
|
3
|
-
- name: Aviary
|
|
4
|
-
zoo_id: 1
|
|
5
|
-
- name: Polar Planet
|
|
6
|
-
zoo_id: 2
|
|
7
|
-
- name: Monkey Mayhem
|
|
8
|
-
zoo_id: 2
|
|
9
|
-
- name: Amazonia
|
|
10
|
-
zoo_id: 3
|
|
11
|
-
- name: Deep Blue Ocean
|
|
12
|
-
zoo_id: 3
|
|
13
|
-
- name: Fish Fight!
|
|
14
|
-
zoo_id: 3
|
|
15
|
-
- name: The Dolphin Show
|
|
16
|
-
zoo_id: 3
|
|
17
|
-
- name: Canal Life
|
|
18
|
-
zoo_id: 4
|
|
19
|
-
- name: The Reptile Pit
|
|
20
|
-
zoo_id: 4
|
|
21
|
-
- name: Kangaroo Exhibit
|
|
22
|
-
zoo_id: 4
|
|
23
|
-
- name: A Million Years Ago...
|
|
24
|
-
zoo_id: 5
|
|
25
|
-
- name: The Wild West
|
|
26
|
-
zoo_id: 5
|
|
27
|
-
- name: Tumble Weeds
|
|
28
|
-
zoo_id: 5
|
|
29
|
-
- name: Missisipi Mud
|
|
30
|
-
zoo_id: 6
|
|
31
|
-
- name: Craw-Daddy's of the Deep!
|
|
32
|
-
zoo_id: 6
|
|
33
|
-
- name: The Littlest Big City
|
|
34
|
-
zoo_id: 7
|
|
35
|
-
- name: Jellyfish On Parade
|
|
36
|
-
zoo_id: 8
|
|
37
|
-
- name: Sea-Life Among the Rigs
|
|
38
|
-
zoo_id: 8
|
|
39
|
-
- name: Monsters of the Rainforest
|
|
40
|
-
zoo_id: 8
|
|
41
|
-
- name: So You Wanna Be A Street-Kid?
|
|
42
|
-
zoo_id: 9
|
|
43
|
-
- name: Don't Feed the Hippies!
|
|
44
|
-
zoo_id: 9
|
|
45
|
-
- name: At the Equator
|
|
46
|
-
zoo_id: 10
|
|
47
|
-
- name: River Habitats
|
|
48
|
-
zoo_id: 10
|
|
49
|
-
- name: A Fiesta of Plant-life
|
|
50
|
-
zoo_id: 10
|
|
51
|
-
- name: Smog World!
|
|
52
|
-
zoo_id: 11
|
|
53
|
-
- name: Where Are They Now? Extinct Species Edition
|
|
54
|
-
zoo_id: 11
|
|
55
|
-
- name: The Fragile Eco-System of the Cheese-Steak
|
|
56
|
-
zoo_id: 12
|
|
57
|
-
- name: Rats!
|
|
58
|
-
zoo_id: 13
|
|
59
|
-
- name: Penguins on Wall St.
|
|
60
|
-
zoo_id: 13
|
|
61
|
-
- name: King of the Jungle
|
|
62
|
-
zoo_id: 13
|
|
63
|
-
- name: The World's Fish-Market
|
|
64
|
-
zoo_id: 14
|
|
65
|
-
- name: Water-World
|
|
66
|
-
zoo_id: 14
|
|
67
|
-
- name: Micro-sized Soft-shelled Crabs
|
|
68
|
-
zoo_id: 14
|
|
69
|
-
- name: Do Animals Like Coffee?
|
|
70
|
-
zoo_id: 14
|
|
71
|
-
- name: On A Clear Day...
|
|
72
|
-
zoo_id: 15
|
|
73
|
-
- name: Twenty Thousand Leagues Under the Sky
|
|
74
|
-
zoo_id: 15
|
|
75
|
-
- name: Closed for Renovation
|
|
76
|
-
zoo_id: 16
|
|
77
|
-
- name: Ducks!
|
|
78
|
-
zoo_id: 17
|
|
79
|
-
- name: Retired Animal Life
|
|
80
|
-
zoo_id: 18
|
|
81
|
-
- name: The Clean Side of the Gulf
|
|
82
|
-
zoo_id: 18
|
|
83
|
-
- name: The Complete History of Rice
|
|
84
|
-
zoo_id: 19
|
|
85
|
-
- name: Safari World
|
|
86
|
-
zoo_id: 19
|
|
87
|
-
- name: Of Mice & Men
|
|
88
|
-
zoo_id: 20
|
|
89
|
-
- name: Snakes!
|
|
90
|
-
zoo_id: 20
|
data/spec/fixtures/fruit.yaml
DELETED
data/spec/fixtures/people.yaml
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
- name: Sam
|
|
2
|
-
age: 29
|
|
3
|
-
occupation: Programmer
|
|
4
|
-
type: Person
|
|
5
|
-
address_street: 1337 Duck Way
|
|
6
|
-
address_city: Galveston
|
|
7
|
-
adresss_state: TX
|
|
8
|
-
address_zip_code: "75000"
|
|
9
|
-
notes:
|
|
10
|
-
date_of_birth: 2007-10-24
|
|
11
|
-
career_name: Programmer
|
|
12
|
-
- name: Amy
|
|
13
|
-
age: 28
|
|
14
|
-
occupation: Business Analyst Manager
|
|
15
|
-
type: Person
|
|
16
|
-
career_name: Business Analyst Manager
|
|
17
|
-
- name: Scott
|
|
18
|
-
age: 25
|
|
19
|
-
occupation: Programmer
|
|
20
|
-
type: SalesPerson
|
|
21
|
-
commission: 172
|
|
22
|
-
career_name: Programmer
|
|
23
|
-
- name: Josh
|
|
24
|
-
age: 23
|
|
25
|
-
occupation: Supervisor
|
|
26
|
-
type:
|
|
27
|
-
career_name: Supervisor
|
|
28
|
-
- name: Bob
|
|
29
|
-
age: 29
|
|
30
|
-
occupation: Peon
|
|
31
|
-
address_street: 123 Happy Ln.
|
|
32
|
-
address_city: Dallas
|
|
33
|
-
address_state: TX
|
|
34
|
-
address_zip_code: "75000"
|
|
35
|
-
type: SalesPerson
|
|
36
|
-
commission: 40
|
|
37
|
-
career_name: Peon
|