aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-03-24 17:02:58 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-24 17:02:58 -0700
commitfe7d3dbb023f7eb08cfa1860ed29ab2cddc92ddb (patch)
treefd83e34a8c8347b9c3c12082d0da27c5f441030b /activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
parente094940c2b5a5163504859efd3a0bcc49c40451e (diff)
downloadrails-fe7d3dbb023f7eb08cfa1860ed29ab2cddc92ddb.tar.gz
rails-fe7d3dbb023f7eb08cfa1860ed29ab2cddc92ddb.tar.bz2
rails-fe7d3dbb023f7eb08cfa1860ed29ab2cddc92ddb.zip
Indentation, superfluous self
Diffstat (limited to 'activesupport/lib/active_support/core_ext/class/delegating_attributes.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/class/delegating_attributes.rb50
1 files changed, 25 insertions, 25 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
index 000ccf4d55..c81af68034 100644
--- a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
+++ b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
@@ -1,31 +1,25 @@
-# These class attributes behave something like the class
-# inheritable accessors. But instead of copying the hash over at
-# the time the subclass is first defined, the accessors simply
-# delegate to their superclass unless they have been given a
-# specific value. This stops the strange situation where values
-# set after class definition don't get applied to subclasses.
class Class
def superclass_delegating_reader(*names)
- class_name_to_stop_searching_on = self.superclass.name.blank? ? "Object" : self.superclass.name
+ class_name_to_stop_searching_on = superclass.name.blank? ? "Object" : superclass.name
names.each do |name|
- class_eval <<-EOS
- def self.#{name} # def self.only_reader
- if defined?(@#{name}) # if defined?(@only_reader)
- @#{name} # @only_reader
- elsif superclass < #{class_name_to_stop_searching_on} && # elsif superclass < Object &&
- superclass.respond_to?(:#{name}) # superclass.respond_to?(:only_reader)
- superclass.#{name} # superclass.only_reader
- end # end
- end # end
- def #{name} # def only_reader
- self.class.#{name} # self.class.only_reader
- end # end
- def self.#{name}? # def self.only_reader?
- !!#{name} # !!only_reader
- end # end
- def #{name}? # def only_reader?
- !!#{name} # !!only_reader
- end # end
+ class_eval(<<-EOS, __FILE__, __LINE__)
+ def self.#{name} # def self.only_reader
+ if defined?(@#{name}) # if defined?(@only_reader)
+ @#{name} # @only_reader
+ elsif superclass < #{class_name_to_stop_searching_on} && # elsif superclass < Object &&
+ superclass.respond_to?(:#{name}) # superclass.respond_to?(:only_reader)
+ superclass.#{name} # superclass.only_reader
+ end # end
+ end # end
+ def #{name} # def only_reader
+ self.class.#{name} # self.class.only_reader
+ end # end
+ def self.#{name}? # def self.only_reader?
+ !!#{name} # !!only_reader
+ end # end
+ def #{name}? # def only_reader?
+ !!#{name} # !!only_reader
+ end # end
EOS
end
end
@@ -40,6 +34,12 @@ class Class
end
end
+ # These class attributes behave something like the class
+ # inheritable accessors. But instead of copying the hash over at
+ # the time the subclass is first defined, the accessors simply
+ # delegate to their superclass unless they have been given a
+ # specific value. This stops the strange situation where values
+ # set after class definition don't get applied to subclasses.
def superclass_delegating_accessor(*names)
superclass_delegating_reader(*names)
superclass_delegating_writer(*names)