开发者

Why is class_inheritable_reader in ActiveSupport not documented?

Pulling my hair out trying to figure out where class_inheritable_reader is documented in Rails.

A Google search revealed its existence, and looking in the gem itself ya find the method:

def class_inheritable_reader(*syms)
  syms.each do |sym|
    next if sym.is_a?(Hash)
    class_eval <<-EOS
      def self.#{sym}                        # def self.be开发者_如何学编程fore_add_for_comments
        read_inheritable_attribute(:#{sym})  #         read_inheritable_attribute(:before_add_for_comments)
      end                                    # end
                                             #
      def #{sym}                             # def before_add_for_comments
        self.class.#{sym}                    #   self.class.before_add_for_comments
      end                                    # end
    EOS
  end
end
....

But looking at the rdocs for both ActiveSupport AND from 'rake doc:rails' you'll find no documentation...how come?


If you open up the folder where gems are installed on your machine, you can navigate to:

activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb

to see where the class is actually implemented. In addition, you can see the latest version of the file in the Rails repository on GitHub.

There is class level documentation available in that file (below), but no method level documentation, which is why you probably couldn't find anything.

# Allows attributes to be shared within an inheritance hierarchy, but where each descendant gets a copy of
# their parents' attributes, instead of just a pointer to the same. This means that the child can add elements
# to, for example, an array without those additions being shared with either their parent, siblings, or
# children, which is unlike the regular class-level attributes that are shared across the entire hierarchy.


I found it on APIdock. It appears to be an extension to Class. No documentation but you can see the implementation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜