lib/couchrest/support/class.rb
def extlib_inheritable_reader(*ivars)
    instance_reader = ivars.pop[:reader] if ivars.last.is_a?(Hash)

    ivars.each do |ivar|
      self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
        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 && !ivar.is_a?(Module) && !ivar.is_a?(Numeric) && !ivar.is_a?(TrueClass) && !ivar.is_a?(FalseClass) ? ivar.dup : ivar
        end
      RUBY
      unless instance_reader == false
        self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def #{ivar}
            self.class.#{ivar}
          end
        RUBY
      end
    end
  end
# Defines class-level inheritable attribute reader. Attributes are available to subclasses,
# each subclass has a copy of parent's attribute.
#
# @param *syms<Array[#to_s]> 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.
Defines class-level inheritable attribute reader. Attributes are available to subclasses,
each subclass has a copy of parent's attribute.
Defines class - level inheritable attribute reader . Attributes are available to subclasses each subclass has a copy of parent ' s attribute .
def extlib_inheritable_reader(*ivars)
    instance_reader = ivars.pop[:reader] if ivars.last.is_a?(Hash)
    ivars.each do |ivar|
      self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
        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 && !ivar.is_a?(Module) && !ivar.is_a?(Numeric) && !ivar.is_a?(TrueClass) && !ivar.is_a?(FalseClass) ? ivar.dup : ivar
        end
      RUBY
      unless instance_reader == false
        self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def #{ivar}
            self.class.#{ivar}
          end
        RUBY
      end
    end
  end
def extlib_inheritable_reader ( * ivars ) instance_reader = ivars . pop [ :reader ] if ivars . last . is_a? ( Hash ) ivars . each do | ivar | self . class_eval <<-RUBY , __FILE__ , __LINE__ + 1 
        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 && !ivar.is_a?(Module) && !ivar.is_a?(Numeric) && !ivar.is_a?(TrueClass) && !ivar.is_a?(FalseClass) ? ivar.dup : ivar
        end
       RUBY unless instance_reader == false self . class_eval <<-RUBY , __FILE__ , __LINE__ + 1 
          def  #{ ivar } 
            self.class. #{ ivar } 
          end
         RUBY end end end
Defines class-level inheritable attribute reader.
Defines class - level inheritable attribute reader .
 Array of attributes converted into inheritable_readers.
Array of attributes converted into inheritable_readers .
#to_s
ivars
*syms<Array>
Array of attributes to define inheritable reader for.
Array of attributes to define inheritable reader for .
api
None
todo
Do we want to block instance_reader via :instance_reader => false
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.
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 .