Method deprecated or moved
This method is deprecated or moved on the latest stable version.
The last existing version (v3.0.9) is shown here.
extlib_inheritable_reader(*ivars, &block)
public
Defines class-level inheritable attribute reader. Attributes are available
to subclasses, each subclass has a copy of parent’s attribute.
@param *syms Array of attributes to define inheritable reader
for. @return <Array[#to_s]> Array of attributes converted into
inheritable_readers.
@api public
@todo Do we want to block instance_reader via :instance_reader => false
@todo It would be preferable that we do something with a Hash passed in
(error out or do the same as other methods above) instead of silently
moving on). In particular, this makes the return value of this function
less useful.
# File activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb, line 187
def extlib_inheritable_reader(*ivars, &block)
options = ivars.extract_options!
ivars.each do |ivar|
self.class_eval def self.#{ivar} return @#{ivar} if self.object_id == #{self.object_id} || defined?(@#{ivar}) ivar = superclass.#{ivar} return nil if ivar.nil? && !#{self}.instance_variable_defined?("@#{ivar}") @#{ivar} = ivar.duplicable? ? ivar.dup : ivar end, __FILE__, __LINE__ + 1
unless options[:instance_reader] == false
self.class_eval def #{ivar} self.class.#{ivar} end, __FILE__, __LINE__ + 1
end
instance_variable_set(:"@#{ivar}", yield) if block_given?
end
end