Skip to content
This repository
Browse code

Changed usage of alias to alias_method

* Currently rdoc chokes when parsing code that uses the alias keyword
  • Loading branch information...
commit 930c01c4d73409835df5f5d1bffce5df0d04722c 1 parent 0e065f5
Dan Kubb authored September 07, 2010
2  lib/dm-core/associations/many_to_many.rb
@@ -27,7 +27,7 @@ def child_key
27 27
         end
28 28
 
29 29
         # @api semipublic
30  
-        alias target_key child_key
  30
+        alias_method :target_key, :child_key
31 31
 
32 32
         # Intermediate association for through model
33 33
         # relationships
12  lib/dm-core/associations/many_to_one.rb
@@ -7,19 +7,19 @@ class Relationship < Associations::Relationship
7 7
         OPTIONS = superclass::OPTIONS.dup << :required << :key
8 8
 
9 9
         # @api semipublic
10  
-        alias source_repository_name child_repository_name
  10
+        alias_method :source_repository_name, :child_repository_name
11 11
 
12 12
         # @api semipublic
13  
-        alias source_model child_model
  13
+        alias_method :source_model, :child_model
14 14
 
15 15
         # @api semipublic
16  
-        alias target_repository_name parent_repository_name
  16
+        alias_method :target_repository_name, :parent_repository_name
17 17
 
18 18
         # @api semipublic
19  
-        alias target_model parent_model
  19
+        alias_method :target_model, :parent_model
20 20
 
21 21
         # @api semipublic
22  
-        alias target_key parent_key
  22
+        alias_method :target_key, :parent_key
23 23
 
24 24
         # @api semipublic
25 25
         def required?
@@ -64,7 +64,7 @@ def child_key
64 64
         end
65 65
 
66 66
         # @api semipublic
67  
-        alias source_key child_key
  67
+        alias_method :source_key, :child_key
68 68
 
69 69
         # Returns a hash of conditions that scopes query that fetches
70 70
         # target object
12  lib/dm-core/associations/one_to_many.rb
@@ -3,19 +3,19 @@ module Associations
3 3
     module OneToMany #:nodoc:
4 4
       class Relationship < Associations::Relationship
5 5
         # @api semipublic
6  
-        alias target_repository_name child_repository_name
  6
+        alias_method :target_repository_name, :child_repository_name
7 7
 
8 8
         # @api semipublic
9  
-        alias target_model child_model
  9
+        alias_method :target_model, :child_model
10 10
 
11 11
         # @api semipublic
12  
-        alias source_repository_name parent_repository_name
  12
+        alias_method :source_repository_name, :parent_repository_name
13 13
 
14 14
         # @api semipublic
15  
-        alias source_model parent_model
  15
+        alias_method :source_model, :parent_model
16 16
 
17 17
         # @api semipublic
18  
-        alias source_key parent_key
  18
+        alias_method :source_key, :parent_key
19 19
 
20 20
         # @api semipublic
21 21
         def child_key
@@ -23,7 +23,7 @@ def child_key
23 23
         end
24 24
 
25 25
         # @api semipublic
26  
-        alias target_key child_key
  26
+        alias_method :target_key, :child_key
27 27
 
28 28
         # Returns a Collection for this relationship with a given source
29 29
         #
2  lib/dm-core/associations/relationship.rb
@@ -209,7 +209,7 @@ def child_key
209 209
       # Access Relationship#child_key directly
210 210
       #
211 211
       # @api private
212  
-      alias relationship_child_key child_key
  212
+      alias_method :relationship_child_key, :child_key
213 213
       private :relationship_child_key
214 214
 
215 215
       # Returns model class used by parent side of the relationship
18  lib/dm-core/collection.rb
@@ -97,8 +97,8 @@ def union(other)
97 97
       set_operation(:|, other)
98 98
     end
99 99
 
100  
-    alias | union
101  
-    alias + union
  100
+    alias_method :|, :union
  101
+    alias_method :+, :union
102 102
 
103 103
     # Return the intersection with another collection
104 104
     #
@@ -113,7 +113,7 @@ def intersection(other)
113 113
       set_operation(:&, other)
114 114
     end
115 115
 
116  
-    alias & intersection
  116
+    alias_method :&, :intersection
117 117
 
118 118
     # Return the difference with another collection
119 119
     #
@@ -128,7 +128,7 @@ def difference(other)
128 128
       set_operation(:-, other)
129 129
     end
130 130
 
131  
-    alias - difference
  131
+    alias_method :-, :difference
132 132
 
133 133
     # Lookup a Resource in the Collection by key
134 134
     #
@@ -367,7 +367,7 @@ def at(offset)
367 367
     # the resources directly so that it can orphan them properly.
368 368
     #
369 369
     # @api private
370  
-    alias superclass_slice slice
  370
+    alias_method :superclass_slice, :slice
371 371
     private :superclass_slice
372 372
 
373 373
     # Simulates Array#slice and returns a new Collection
@@ -406,7 +406,7 @@ def [](*args)
406 406
       end
407 407
     end
408 408
 
409  
-    alias slice []
  409
+    alias_method :slice, :[]
410 410
 
411 411
     # Deletes and Returns the Resources given by an offset or a Range
412 412
     #
@@ -466,7 +466,7 @@ def []=(*args)
466 466
       resources
467 467
     end
468 468
 
469  
-    alias splice []=
  469
+    alias_method :splice, :[]=
470 470
 
471 471
     # Return a copy of the Collection sorted in reverse
472 472
     #
@@ -526,7 +526,7 @@ def collect!
526 526
       super { |resource| resource_added(yield(resource_removed(resource))) }
527 527
     end
528 528
 
529  
-    alias map! collect!
  529
+    alias_method :map!, :collect!
530 530
 
531 531
     # Append one Resource to the Collection and relate it
532 532
     #
@@ -690,7 +690,7 @@ def reject!
690 690
     # Access LazyArray#replace directly
691 691
     #
692 692
     # @api private
693  
-    alias superclass_replace replace
  693
+    alias_method :superclass_replace, :replace
694 694
     private :superclass_replace
695 695
 
696 696
     # Replace the Resources within the Collection
4  lib/dm-core/core_ext/pathname.rb
@@ -13,8 +13,8 @@ def /(path)
13 13
     (self + path).expand_path
14 14
   end
15 15
 
16  
-  # alias to_s to to_str when to_str not defined
  16
+  # alias_method :to_s, :to to_str when to_str not defined
17 17
   unless public_instance_methods(false).any? { |m| m.to_sym == :to_str }
18  
-    alias to_str to_s
  18
+    alias_method :to_str, :to_s
19 19
   end
20 20
 end # class Pathname
2  lib/dm-core/model.rb
@@ -297,7 +297,7 @@ def [](*args)
297 297
       all[*args]
298 298
     end
299 299
 
300  
-    alias slice []
  300
+    alias_method :slice, :[]
301 301
 
302 302
     def at(*args)
303 303
       all.at(*args)
2  lib/dm-core/property_set.rb
@@ -15,7 +15,7 @@ def [](name)
15 15
       @properties[name]
16 16
     end
17 17
 
18  
-    alias superclass_slice []=
  18
+    alias_method :superclass_slice, :[]=
19 19
     private :superclass_slice
20 20
 
21 21
     # @api semipublic
10  lib/dm-core/query.rb
@@ -430,8 +430,8 @@ def union(other)
430 430
       set_operation(:union, other)
431 431
     end
432 432
 
433  
-    alias | union
434  
-    alias + union
  433
+    alias_method :|, :union
  434
+    alias_method :+, :union
435 435
 
436 436
     # Return the intersection with another query
437 437
     #
@@ -447,7 +447,7 @@ def intersection(other)
447 447
       set_operation(:intersection, other)
448 448
     end
449 449
 
450  
-    alias & intersection
  450
+    alias_method :&, :intersection
451 451
 
452 452
     # Return the difference with another query
453 453
     #
@@ -462,7 +462,7 @@ def difference(other)
462 462
       set_operation(:difference, other)
463 463
     end
464 464
 
465  
-    alias - difference
  465
+    alias_method :-, :difference
466 466
 
467 467
     # Clear conditions
468 468
     #
@@ -568,7 +568,7 @@ def slice(*args)
568 568
       dup.slice!(*args)
569 569
     end
570 570
 
571  
-    alias [] slice
  571
+    alias_method :[], :slice
572 572
 
573 573
     # Slices collection by adding limit and offset to the
574 574
     # query, so a single query is executed
10  lib/dm-core/query/conditions/operation.rb
@@ -88,7 +88,7 @@ class AbstractOperation
88 88
         # @api semipublic
89 89
         attr_reader :operands
90 90
 
91  
-        alias children operands
  91
+        alias_method :children, :operands
92 92
 
93 93
         # Returns the classes that inherit from AbstractComparison
94 94
         #
@@ -232,8 +232,8 @@ def union(other)
232 232
           Operation.new(:or, dup, other.dup).minimize
233 233
         end
234 234
 
235  
-        alias | union
236  
-        alias + union
  235
+        alias_method :|, :union
  236
+        alias_method :+, :union
237 237
 
238 238
         # Return the intersection of the operation and another operand
239 239
         #
@@ -248,7 +248,7 @@ def intersection(other)
248 248
           Operation.new(:and, dup, other.dup).minimize
249 249
         end
250 250
 
251  
-        alias & intersection
  251
+        alias_method :&, :intersection
252 252
 
253 253
         # Return the difference of the operation and another operand
254 254
         #
@@ -263,7 +263,7 @@ def difference(other)
263 263
           Operation.new(:and, dup, Operation.new(:not, other.dup)).minimize
264 264
         end
265 265
 
266  
-        alias - difference
  266
+        alias_method :-, :difference
267 267
 
268 268
         # Minimize the operation
269 269
         #
2  lib/dm-core/repository.rb
@@ -46,7 +46,7 @@ def self.default_name
46 46
     attr_reader :name
47 47
 
48 48
     # @api semipublic
49  
-    alias to_sym name
  49
+    alias_method :to_sym, :name
50 50
 
51 51
     # Get the adapter for this repository
52 52
     #
4  lib/dm-core/resource.rb
@@ -254,7 +254,7 @@ def attribute_get(name)
254 254
       persisted_state.get(properties[name])
255 255
     end
256 256
 
257  
-    alias [] attribute_get
  257
+    alias_method :[], :attribute_get
258 258
 
259 259
     # Sets the value of the attribute and marks the attribute as dirty
260 260
     # if it has been changed so that it may be saved. Do not set from
@@ -295,7 +295,7 @@ def attribute_set(name, value)
295 295
       self.persisted_state = persisted_state.set(properties[name], value)
296 296
     end
297 297
 
298  
-    alias []= attribute_set
  298
+    alias_method :[]=, :attribute_set
299 299
 
300 300
     # Gets all the attributes of the Resource instance
301 301
     #
2  lib/dm-core/spec/setup.rb
@@ -96,7 +96,7 @@ def adapter
96 96
           @adapter ||= setup!
97 97
         end
98 98
 
99  
-        alias :setup :adapter
  99
+        alias_method :setup, :adapter
100 100
 
101 101
         def setup!
102 102
           adapter = DataMapper.setup(name, connection_uri)
8  lib/dm-core/support/lazy_array.rb
@@ -116,7 +116,7 @@ def [](*args)
116 116
     end
117 117
   end
118 118
 
119  
-  alias slice []
  119
+  alias_method :slice, :[]
120 120
 
121 121
   def slice!(*args)
122 122
     index, length = extract_slice_arguments(*args)
@@ -144,7 +144,7 @@ def []=(*args)
144 144
     end
145 145
   end
146 146
 
147  
-  alias splice []=
  147
+  alias_method :splice, :[]=
148 148
 
149 149
   def reverse
150 150
     dup.reverse!
@@ -278,7 +278,7 @@ def to_a
278 278
     @array.to_a
279 279
   end
280 280
 
281  
-  alias to_ary to_a
  281
+  alias_method :to_ary, :to_a
282 282
 
283 283
   def load_with(&block)
284 284
     @load_with_proc = block
@@ -293,7 +293,7 @@ def kind_of?(klass)
293 293
     super || @array.kind_of?(klass)
294 294
   end
295 295
 
296  
-  alias is_a? kind_of?
  296
+  alias_method :is_a?, :kind_of?
297 297
 
298 298
   def respond_to?(method, include_private = false)
299 299
     super || @array.respond_to?(method)
2  lib/dm-core/support/logger.rb
@@ -153,7 +153,7 @@ def <<(string = nil)
153 153
 
154 154
       message
155 155
     end
156  
-    alias :push :<<
  156
+    alias_method :push, :<<
157 157
 
158 158
     # Generate the logging methods for Extlib.logger for each log level.
159 159
     Levels.each_pair do |name, number|
8  spec/semipublic/shared/resource_state_shared_spec.rb
@@ -2,9 +2,9 @@
2 2
   it 'should delegate to the superclass' do
3 3
     # this is the only way I could think of to test if the
4 4
     # superclass method is being called
5  
-    DataMapper::Resource::State.class_eval { alias original_set set; undef_method(:set) }
  5
+    DataMapper::Resource::State.class_eval { alias_method :original_set, :set; undef_method(:set) }
6 6
     method(:subject).should raise_error(NoMethodError)
7  
-    DataMapper::Resource::State.class_eval { alias set original_set; undef_method(:original_set) }
  7
+    DataMapper::Resource::State.class_eval { alias_method :set, :original_set; undef_method(:original_set) }
8 8
   end
9 9
 end
10 10
 
@@ -12,9 +12,9 @@
12 12
   it 'should delegate to the superclass' do
13 13
     # this is the only way I could think of to test if the
14 14
     # superclass method is not being called
15  
-    DataMapper::Resource::State.class_eval { alias original_set set; undef_method(:set) }
  15
+    DataMapper::Resource::State.class_eval { alias_method :original_set, :set; undef_method(:set) }
16 16
     method(:subject).should_not raise_error(NoMethodError)
17  
-    DataMapper::Resource::State.class_eval { alias set original_set; undef_method(:original_set) }
  17
+    DataMapper::Resource::State.class_eval { alias_method :set, :original_set; undef_method(:original_set) }
18 18
   end
19 19
 end
20 20
 

0 notes on commit 930c01c

Please sign in to comment.
Something went wrong with that request. Please try again.