public
Rubygem
Description: DataMapper - Core
Homepage: http://datamapper.org
Clone URL: git://github.com/sam/dm-core.git
Search Repo:
Whitespace cleanup
myabc (author)
Tue May 13 02:34:02 -0700 2008
commit  0956c1206c3960749588b03bbbbc411a71aace3e
tree    36481e4ae2bf38adc162140b2749f25c59c3081a
parent  07cdcc271dbdd18ba80b6a2c472b0ad43696e10e
...
14
15
16
17
 
18
19
20
...
32
33
34
35
 
36
37
38
...
56
57
58
59
 
60
61
62
63
64
65
66
67
...
103
104
105
106
 
107
108
109
110
 
111
112
113
114
 
115
116
117
118
 
119
120
121
122
 
123
124
125
126
 
127
128
129
...
14
15
16
 
17
18
19
20
...
32
33
34
 
35
36
37
38
...
56
57
58
 
59
60
61
62
63
64
65
66
67
...
103
104
105
 
106
107
108
109
 
110
111
112
113
 
114
115
116
117
 
118
119
120
121
 
122
123
124
125
 
126
127
128
129
0
@@ -14,7 +14,7 @@
0
 
0
       attr_reader :name, :uri
0
       attr_accessor :resource_naming_convention, :field_naming_convention
0
-
0
+
0
       def type_map
0
         self.class.type_map
0
       end
0
@@ -32,7 +32,7 @@
0
 
0
       #
0
       # Pushes the given Transaction onto the per thread Transaction stack so that
0
- # everything done by this Adapter is done within the context of said
0
+ # everything done by this Adapter is done within the context of said
0
       # Transaction.
0
       #
0
       # ==== Parameters
0
@@ -56,7 +56,7 @@
0
 
0
       #
0
       # Retrieve the current transaction for this Adapter.
0
- #
0
+ #
0
       # Everything done by this Adapter is done within the context of this Transaction.
0
       #
0
       # ==== Returns
0
0
0
0
0
0
@@ -103,27 +103,27 @@
0
       def delete(repository, resource)
0
         raise NotImplementedError
0
       end
0
-
0
+
0
       def create_model_storage(repository, model)
0
         raise NotImplementedError
0
       end
0
-
0
+
0
       def destroy_model_storage(repository, model)
0
         raise NotImplementedError
0
       end
0
-
0
+
0
       def alter_model_storage(repository, *args)
0
         raise NotImplementedError
0
       end
0
-
0
+
0
       def create_property_storage(repository, property)
0
         raise NotImplementedError
0
       end
0
-
0
+
0
       def destroy_property_storage(repository, property)
0
         raise NotImplementedError
0
       end
0
-
0
+
0
       def alter_property_storage(repository, *args)
0
         raise NotImplementedError
0
       end
...
93
94
95
96
 
97
98
99
...
93
94
95
 
96
97
98
99
0
@@ -93,7 +93,7 @@
0
       raise ArgumentError.new("target_method should be a symbol") unless name.is_a?(Symbol)
0
       raise ArgumentError.new("method_sym should be a symbol") if method_sym && ! method_sym.is_a?(Symbol)
0
       raise ArgumentError.new("You need to pass :class or :instance as scope") unless [:class, :instance].include?(scope)
0
-
0
+
0
       hooks_with_scope(scope)[name][type] ||= []
0
 
0
       hooks_with_scope(scope)[name][type] << if block
...
16
17
18
19
 
20
21
22
23
24
 
25
26
 
27
28
29
30
...
49
50
51
52
 
53
54
55
 
 
56
57
58
...
115
116
117
118
 
119
120
121
...
156
157
158
159
160
 
 
161
162
163
...
176
177
178
179
 
180
181
182
...
192
193
194
195
 
196
...
16
17
18
 
19
20
21
22
23
 
24
25
 
26
27
28
29
30
...
49
50
51
 
52
53
 
 
54
55
56
57
58
...
115
116
117
 
118
119
120
121
...
156
157
158
 
 
159
160
161
162
163
...
176
177
178
 
179
180
181
182
...
192
193
194
 
195
196
0
@@ -16,14 +16,14 @@
0
 # DataMapper.logger.info(message<String>)
0
 # DataMapper.logger.debug(message<String>)
0
 #
0
-# Flush the buffer to
0
+# Flush the buffer to
0
 # DataMapper.logger.flush
0
 #
0
 # Remove the current log object
0
 # DataMapper.logger.close
0
-#
0
+#
0
 # ==== Private DataMapper Logger API
0
-#
0
+#
0
 # To initialize the logger you create a new object, proxies to set_log.
0
 # DataMapper::Logger.new(log{String, IO},level{Symbol, String})
0
 module DataMapper
0
0
@@ -49,10 +49,10 @@
0
     # debug: low-level information for developers
0
     #
0
     # DataMapper::Logger::LEVELS[:fatal, :error, :warn, :info, :debug]
0
- LEVELS =
0
+ LEVELS =
0
     {
0
- :fatal => 7,
0
- :error => 6,
0
+ :fatal => 7,
0
+ :error => 6,
0
       :warn => 4,
0
       :info => 3,
0
       :debug => 0
0
@@ -115,7 +115,7 @@
0
 
0
     # To replace an existing logger with a new one:
0
     # DataMapper::Logger.set_log(log{String, IO},level{Symbol, String})
0
- #
0
+ #
0
     # ==== Parameters
0
     # log<IO,String>
0
     # Either an IO object or a name of a logfile.
0
@@ -156,8 +156,8 @@
0
       @log = nil
0
     end
0
 
0
- # Appends a string and log level to logger's buffer.
0
- # Note that the string is discarded if the string's log level less than the logger's log level.
0
+ # Appends a string and log level to logger's buffer.
0
+ # Note that the string is discarded if the string's log level less than the logger's log level.
0
     # Note that if the logger is aio capable then the logger will use non-blocking asynchronous writes.
0
     #
0
     # ==== Parameters
0
@@ -176,7 +176,7 @@
0
     alias << push
0
 
0
     # Generate the following logging methods for DataMapper.logger as described in the api:
0
- # :fatal, :error, :warn, :info, :debug
0
+ # :fatal, :error, :warn, :info, :debug
0
     LEVELS.each_pair do |name, number|
0
       class_eval <<-LEVELMETHODS, __FILE__, __LINE__
0
       # DOC
0
@@ -192,6 +192,6 @@
0
     end
0
 
0
   end # class Logger
0
-
0
+
0
 end # module DataMapper
...
3
4
5
6
 
7
8
9
10
 
11
12
13
 
14
15
16
17
18
19
20
 
21
22
23
...
25
26
27
28
...
3
4
5
 
6
7
8
9
 
10
11
12
 
13
14
15
16
17
18
19
 
20
21
22
23
...
25
26
27
 
0
@@ -3,21 +3,21 @@
0
     def self.subclasses
0
       @@subclasses ||= []
0
     end
0
-
0
+
0
     def self.subclasses=(obj)
0
       @@subclasses = obj
0
     end
0
-
0
+
0
     def self.inherited(klass)
0
       subclasses << klass
0
-
0
+
0
       class << klass
0
         def models
0
           @models ||= []
0
         end
0
       end
0
     end
0
-
0
+
0
     def self.migrate(repository_name)
0
       subclasses.collect do |migrator|
0
         migrator.migrate(repository_name)
0
@@ -25,5 +25,4 @@
0
     end
0
   end
0
 end
0
-
...
1
2
 
3
4
5
6
7
8
 
9
10
11
12
13
14
15
16
...
21
22
23
24
 
25
26
27
28
29
30
 
31
32
33
 
34
35
36
 
37
38
39
40
41
42
 
43
44
45
46
47
48
 
49
50
...
1
 
2
3
4
5
6
7
 
8
9
10
11
12
13
14
15
16
...
21
22
23
 
24
25
26
27
28
29
 
30
31
32
 
33
34
35
 
36
37
38
39
40
41
 
42
43
44
45
46
47
 
48
49
50
0
@@ -1,11 +1,11 @@
0
 module DataMapper
0
-
0
+
0
   # Use these modules to set naming conventions.
0
   # The default is UnderscoredAndPluralized.
0
   # You assign a naming convention like so:
0
   #
0
   # repository(:default).adapter.resource_naming_convention = NamingConventions::Underscored
0
- #
0
+ #
0
   # You can also easily assign a custom convention with a Proc:
0
   #
0
   # repository(:default).adapter.resource_naming_convention = lambda do |value|
0
0
0
0
0
0
@@ -21,31 +21,31 @@
0
   # adapter = DataMapper.setup(:default, "mock://localhost/mock")
0
   # adapter.resource_naming_convention = DataMapper::NamingConventions::Underscored
0
   module NamingConventions
0
-
0
+
0
     module UnderscoredAndPluralized
0
       def self.call(value)
0
         DataMapper::Inflection.pluralize(DataMapper::Inflection.underscore(value)).gsub('/','_')
0
       end
0
     end # module UnderscoredAndPluralized
0
-
0
+
0
     module UnderscoredAndPluralizedWithoutModule
0
       def self.call(value)
0
- DataMapper::Inflection.pluralize(DataMapper::Inflection.underscore(DataMapper::Inflection.demodulize(value)))
0
+ DataMapper::Inflection.pluralize(DataMapper::Inflection.underscore(DataMapper::Inflection.demodulize(value)))
0
       end
0
     end # module UnderscoredAndPluralizedWithoutModule
0
-
0
+
0
     module Underscored
0
       def self.call(value)
0
         DataMapper::Inflection.underscore(value)
0
       end
0
     end # module Underscored
0
-
0
+
0
     module Yaml
0
       def self.call(value)
0
         DataMapper::Inflection.pluralize(DataMapper::Inflection.underscore(value)) + ".yaml"
0
       end
0
     end # module Yaml
0
-
0
+
0
   end # module NamingConventions
0
 end # module DataMapper
...
116
117
118
119
 
120
121
 
122
123
124
...
116
117
118
 
119
120
 
121
122
123
124
0
@@ -116,9 +116,9 @@
0
         r__dup
0
       end
0
     end
0
-
0
+
0
     private
0
-
0
+
0
     def initialize(properties = [])
0
       raise ArgumentError, "+properties+ should be an Array, but was #{properties.class}", caller unless Array === properties
0
 
...
9
10
11
12
 
13
14
15
...
9
10
11
 
12
13
14
15
0
@@ -9,7 +9,7 @@
0
   class RepositoryNotSetupError < StandardError; end
0
 
0
   class IncompleteResourceError < StandardError; end
0
-
0
+
0
   class PersistenceError < StandardError; end
0
 end # module DataMapper
0
 
...
3
4
5
6
 
7
...
3
4
5
 
6
7
0
@@ -3,6 +3,6 @@
0
   # Will not overwrite if a method of the same name is pre-defined.
0
   def repository(*args, &block)
0
     DataMapper.repository(*args, &block)
0
- end
0
+ end
0
 end # module Kernel
...
1
 
2
3
4
5
6
7
 
8
9
10
11
 
12
13
14
...
17
18
19
20
 
21
...
 
1
2
3
4
5
6
 
7
8
9
10
 
11
12
13
14
...
17
18
19
 
20
21
0
@@ -1,14 +1,14 @@
0
-class Object
0
+class Object
0
   unless instance_methods.include?('instance_variable_defined?')
0
     def instance_variable_defined?(method)
0
       instance_variables.include?(method.to_s)
0
     end
0
   end
0
-
0
+
0
   def find_const(nested_name)
0
     NESTED_CONSTANTS[nested_name]
0
   end
0
-
0
+
0
   private
0
   NESTED_CONSTANTS = Hash.new do |h,k|
0
     klass = Object
0
@@ -17,6 +17,6 @@
0
     end
0
     h[k] = klass
0
   end
0
-
0
+
0
 end # class Object
...
1
2
 
3
4
5
...
29
30
31
32
33
 
 
34
35
36
...
68
69
70
71
72
 
 
73
74
75
...
1
 
2
3
4
5
...
29
30
31
 
 
32
33
34
35
36
...
68
69
70
 
 
71
72
73
74
75
0
@@ -1,5 +1,5 @@
0
 module DataMapper
0
-
0
+
0
   class Transaction
0
 
0
     attr_reader :transaction_primitives, :adapters, :state
0
@@ -29,8 +29,8 @@
0
     # DataMapper::Repositories will have their @adapters added.
0
     # DataMapper::Resource subclasses will have all the repositories of all their properties added.
0
     # DataMapper::Resource instances will have all repositories of all their properties added.
0
- # block<Block>:: A block (taking one argument, the Transaction) to execute within this
0
- # transaction. The transaction will begin and commit around the block, and rollback if
0
+ # block<Block>:: A block (taking one argument, the Transaction) to execute within this
0
+ # transaction. The transaction will begin and commit around the block, and rollback if
0
     # an exception is raised.
0
     #
0
     def link(*things, &block)
0
@@ -68,8 +68,8 @@
0
     # Commit the transaction
0
     #
0
     # ==== Parameters
0
- # block<Block>:: A block (taking the one argument, the Transaction) to execute within this
0
- # transaction. The transaction will begin and commit around the block, and rollback if
0
+ # block<Block>:: A block (taking the one argument, the Transaction) to execute within this
0
+ # transaction. The transaction will begin and commit around the block, and rollback if
0
     # an exception is raised.
0
     #
0
     # If no block is given, it will simply commit any changes made since the Transaction did #begin.
...
158
159
160
161
 
162
163
 
164
165
166
...
158
159
160
 
161
162
 
163
164
165
166
0
@@ -158,9 +158,9 @@
0
     def self.load(value, property)
0
       value
0
     end
0
-
0
+
0
     def self.bind(property)
0
- # This method should not modify the state of this type class, and
0
+ # This method should not modify the state of this type class, and
0
       # should produce no side-effects on the type class. It's just a
0
       # hook to allow your custom-type to modify the property it's bound to.
0
     end
...
1
2
3
 
4
5
 
6
7
8
 
9
10
11
 
12
13
14
15
 
16
17
18
19
...
20
21
22
23
 
24
25
26
27
 
28
29
30
31
32
33
34
35
36
37
...
32
33
34
35
 
36
37
38
39
40
41
 
42
43
 
44
45
46
47
 
48
49
50
 
51
52
53
54
 
55
56
57
58
59
 
60
61
62
63
64
65
 
66
67
68
...
1
2
 
3
4
 
5
6
7
 
8
9
10
 
11
12
13
14
 
15
16
17
18
19
...
20
21
22
 
23
24
25
26
 
27
28
29
30
31
32
33
34
35
36
37
...
32
33
34
 
35
36
37
38
39
40
 
41
42
 
43
44
45
46
 
47
48
49
 
50
51
52
53
 
54
55
56
57
58
 
59
60
61
62
63
64
 
65
66
67
68
0
@@ -1,18 +1,18 @@
0
 module DataMapper
0
   class TypeMap
0
-
0
+
0
     attr_accessor :parent, :chains
0
-
0
+
0
     def initialize(parent = nil, &blk)
0
       @parent, @chains = parent, {}
0
-
0
+
0
       blk.call(self) unless blk.nil?
0
     end
0
-
0
+
0
     def map(type)
0
       @chains[type] ||= TypeChain.new
0
     end
0
-
0
+
0
     def lookup(type)
0
       if type_mapped?(type)
0
         lookup_from_map(type)
0
0
@@ -20,11 +20,11 @@
0
         lookup_by_type(type)
0
       end
0
     end
0
-
0
+
0
     def lookup_from_map(type)
0
       lookup_from_parent(type).merge(map(type).translate)
0
     end
0
-
0
+
0
     def lookup_from_parent(type)
0
       if !@parent.nil? && @parent.type_mapped?(type)
0
         @parent[type]
0
0
0
0
0
0
0
0
@@ -32,37 +32,37 @@
0
         {}
0
       end
0
     end
0
-
0
+
0
     def lookup_by_type(type)
0
       raise "TypeMap Exception: type #{type} must have a default primitive or type map entry" unless type.respond_to?(:primitive) && !type.primitive.nil?
0
 
0
       lookup(type.primitive).merge(Type::PROPERTY_OPTIONS.inject({}) {|h, k| h[k] = type.send(k); h})
0
     end
0
-
0
+
0
     alias [] lookup
0
-
0
+
0
     def type_mapped?(type)
0
       @chains.has_key?(type) || (@parent.nil? ? false : @parent.type_mapped?(type))
0
     end
0
-
0
+
0
     class TypeChain
0
       attr_accessor :primitive, :attributes
0
-
0
+
0
       def initialize
0
         @attributes = {}
0
       end
0
-
0
+
0
       def to(primitive)
0
         @primitive = primitive
0
         self
0
       end
0
-
0
+
0
       def with(attributes)
0
         raise "method 'with' expects a hash" unless Hash === attributes
0
         @attributes.merge!(attributes)
0
         self
0
       end
0
-
0
+
0
       def translate
0
         @attributes.merge((@primitive.nil? ? {} : {:primitive => @primitive}))
0
       end
...
3
4
5
6
 
7
...
3
4
5
 
6
7
0
@@ -3,6 +3,6 @@
0
     class Boolean < DataMapper::Type
0
       primitive TrueClass
0
     end # class Boolean
0
- end # module Types
0
+ end # module Types
0
 end # module DataMapper
...
14
15
16
17
 
18
19
20
 
 
21
22
23
...
14
15
16
 
17
18
 
 
19
20
21
22
23
0
@@ -14,10 +14,10 @@
0
             save
0
           end
0
         EOS
0
-
0
+
0
         model.send(:scope_stack) << DataMapper::Query.new(repository, model, property.name => nil)
0
-
0
- end
0
+
0
+ end
0
     end
0
   end
0
 end
...
13
14
15
16
 
17
18
19
 
 
20
21
22
...
13
14
15
 
16
17
 
 
18
19
20
21
22
0
@@ -13,10 +13,10 @@
0
             save
0
           end
0
         EOS
0
-
0
+
0
         model.send(:scope_stack) << DataMapper::Query.new(repository, model, property.name => nil)
0
-
0
- end
0
+
0
+ end
0
     end
0
   end
0
 end
...
6
7
8
9
 
10
...
6
7
8
 
9
10
0
@@ -6,6 +6,6 @@
0
       size 65535
0
       lazy true
0
     end # class Text
0
- end # module Types
0
+ end # module Types
0
 end # module DataMapper
...
2
3
4
5
 
6
7
 
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
12
13
14
15
 
16
17
18
19
20
 
21
22
23
24
25
 
26
27
 
28
29
 
30
31
32
 
33
34
 
35
36
37
38
 
39
40
41
42
 
43
44
45
46
 
47
48
49
50
 
51
52
53
54
 
55
56
57
58
59
 
60
61
62
...
66
67
68
69
 
70
...
2
3
4
 
5
6
 
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
12
13
14
 
15
16
17
18
19
 
20
21
22
23
24
 
25
26
 
27
28
 
29
30
31
 
32
33
 
34
35
36
37
 
38
39
40
41
 
42
43
44
45
 
46
47
48
49
 
50
51
52
53
 
54
55
56
57
58
 
59
60
61
62
...
66
67
68
 
69
70
0
@@ -2,9 +2,9 @@
0
 
0
 if HAS_SQLITE3
0
   describe 'association proxying' do
0
-
0
+
0
     before(:all) do
0
-
0
+
0
       class Zebra
0
         include DataMapper::Resource
0
 
0
0
0
0
0
0
0
0
0
0
0
0
0
@@ -12,51 +12,51 @@
0
         property :name, String
0
         property :age, Integer
0
         has n, :stripes
0
-
0
+
0
       end
0
 
0
       class Stripe
0
         include DataMapper::Resource
0
-
0
+
0
         property :id, Integer, :serial => true
0
         property :name, String
0
         property :age, Integer
0
         property :zebra_id, Integer
0
-
0
+
0
         belongs_to :zebra
0
-
0
+
0
       end
0
-
0
+
0
       Zebra.auto_migrate!(:sqlite3)
0
       Stripe.auto_migrate!(:sqlite3)
0
-
0
+
0
       repository(:sqlite3) do
0
-
0
+
0
         nancy = Zebra.new(:age => 11)
0
         nancy.name = 'nance'
0
         nancy.save
0
-
0
+
0
         bessie = Zebra.new(:age => 10)
0
         bessie.name = 'Bessie'
0
         bessie.save
0
-
0
+
0
         steve = Zebra.new(:age => 8)
0
         steve.name = 'Steve'
0
         steve.save
0
-
0
+
0
         @babe = Stripe.new
0
         @babe.name = 'Babe'
0
         @babe.save
0
-
0
+
0
         @snowball = Stripe.new
0
         @snowball.name = 'snowball'
0
         @snowball.save
0
-
0
+
0
         nancy.stripes << @babe
0
         nancy.stripes << @snowball
0
       end
0
     end
0
-
0
+
0
     it "should proxy the relationships of the model" do
0
       repository(:sqlite3) do
0
         zebras = Zebra.all
0
@@ -66,6 +66,6 @@
0
       end
0
     end
0
&nb