lib/utilrb/models/inherited_enumerable.rb
# Helper method for inherited_enumerable
#
# It is called in the context of the singleton class of the module/class on
# which inherited_enumerable is called
Helper method for inherited_enumerable
It is called in the context of the singleton class of the module/class on
which inherited_enumerable is called
Helper method for inherited_enumerable It is called in the context of the singleton class of the module / class on which inherited_enumerable is called
def define_inherited_enumerable_nomap_with_promotion(name, attribute_name, options)
        class_eval <<-EOF, __FILE__, __LINE__+1
        def each_#{name}
            if !block_given?
                return enum_for(:each_#{name})
            end
            ancestors = self.ancestors
            if ancestors.first != self
                ancestors.unshift self
            end
            promotions = []
            for klass in ancestors
                if klass.instance_variable_defined?(:@#{attribute_name})
                    klass.#{attribute_name}.#{options[:enum_with]} do |value|
                        for p in promotions
                            value = p.promote_#{name}(value)
                        end
                        yield(value)
                    end
                end
                promotions.unshift(klass) if klass.respond_to?("promote_#{name}")
            end
            self
        end
        EOF
    end
def define_inherited_enumerable_nomap_with_promotion ( name , attribute_name , options ) class_eval <<-EOF , __FILE__ , __LINE__ + 1 
        def each_ #{ name } 
            if !block_given?
                return enum_for(:each_ #{ name } )
            end

            ancestors = self.ancestors
            if ancestors.first != self
                ancestors.unshift self
            end
            promotions = []
            for klass in ancestors
                if klass.instance_variable_defined?(:@ #{ attribute_name } )
                    klass. #{ attribute_name } . #{ options [ :enum_with ] }  do |value|
                        for p in promotions
                            value = p.promote_ #{ name } (value)
                        end
                        yield(value)
                    end
                end
                promotions.unshift(klass) if klass.respond_to?("promote_ #{ name } ")
            end
            self
        end
         EOF end
Helper method for inherited_enumerable
It is called in the context of the singleton class of the module/class on
which inherited_enumerable is called
Helper method for inherited_enumerable It is called in the context of the singleton class of the module / class on which inherited_enumerable is called
name
<not_specific>
attribute_name
<not_specific>
options
<not_specific>