diff options
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/rails_guides/generator.rb | 2 | ||||
-rw-r--r-- | railties/guides/rails_guides/indexer.rb | 4 | ||||
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 83 | ||||
-rw-r--r-- | railties/guides/source/layout.html.erb | 2 |
4 files changed, 83 insertions, 8 deletions
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index d4796b65c1..bd25111405 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -101,7 +101,7 @@ module RailsGuides view.content_tag(:li, l) end - children_ul = view.content_tag(:ul, children) + children_ul = view.content_tag(:ul, children.join(" ")) index << view.content_tag(:li, link + children_ul) end diff --git a/railties/guides/rails_guides/indexer.rb b/railties/guides/rails_guides/indexer.rb index 5b5ad3fee1..939404c85f 100644 --- a/railties/guides/rails_guides/indexer.rb +++ b/railties/guides/rails_guides/indexer.rb @@ -19,9 +19,9 @@ module RailsGuides level_hash = ActiveSupport::OrderedHash.new while !s.eos? - s.match?(/\h[0-9]\..*$/) + s.match?(/h[0-9]\..*$/) if matched = s.matched - matched =~ /\h([0-9])\.(.*)$/ + matched =~ /h([0-9])\.(.*)$/ level, title = $1.to_i, $2 if level < current_level diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 3073c3a7a5..f8a72db703 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -323,6 +323,46 @@ TIP: Since +with_options+ forwards calls to its receiver they can be nested. Eac NOTE: Defined in +active_support/core_ext/object/with_options.rb+. +h4. Modules and Classes + +h5. +remove_subclasses_of+ + +The method +remove_subclasses_of+ receives an arbitrary number of class objects and removes their subclasses. It is a wrapper of +Class#remove_class+ explained with more details in "Class Removal FIX THIS LINK":FIXME. + +h5. +subclasses_of+ + +The method +subclasses_of+ receives an arbitrary number of class objects and returns all their anonymous or reachable descendants as a single array: + +<ruby> +class C; end +subclasses_of(C) # => [] + +subclasses_of(Integer) # => [Bignum, Fixnum] + +module M + class A; end + class B1 < A; end + class B2 < A; end +end + +module N + class C < M::B1; end +end + +subclasses_of(M::A) # => [N::C, M::B2, M::B1] +</ruby> + +The order in which these classes are returned is unspecified. The returned collection may have duplicates: + +<ruby> +subclasses_of(Numeric, Integer) +# => [Bignum, Float, Fixnum, Integer, Date::Infinity, Rational, BigDecimal, Bignum, Fixnum] +</ruby> + +See also +Class#subclasses+ in "Extensions to +Class+ FIXME THIS LINK":FIXME. + +NOTE: Defined in +active_support/core_ext/object/extending.rb+. + h4. Instance Variables Active Support provides several methods to ease access to instance variables. @@ -587,9 +627,19 @@ If for whatever reason an application loads the definition of a mailer class and NOTE: Defined in +active_support/core_ext/class/delegating_attributes.rb+. -h4. Subclasses +h4. Descendants + +h5. +descendents+ + +The +descendents+ method returns all the descendants of its receiver as an array of class objects. This method performs no filtering so non-reachable classes are included, if any. -The +subclasses+ method returns the names of all subclasses of a given class as an array of strings. That comprises not only direct subclasses, but all descendants down the hierarchy: +See aso +Object#subclasses_of+, explained in "Extensions to All Objects FIX THIS LINK":FIXME. + +NOTE: Defined in +active_support/core_ext/object/extending.rb+. + +h5. +subclasses+ + +The +subclasses+ method returns the names of all the anonymous or reachable descendants of its receiver as an array of strings: <ruby> class C; end @@ -610,9 +660,9 @@ end M::A.subclasses # => ["N::C", "M::B2", "M::B1"] </ruby> -The order in which these class names are returned is unspecified. +WARNING: +ActiveRecord::Base+ redefines +subclasses+, it returns class objects, reachable or not, and it is protected. -See also +Object#subclasses_of+ in "Extensions to All Objects FIX THIS LINK":FIXME. +See aso +Object#subclasses_of+, explained in "Extensions to All Objects FIX THIS LINK":FIXME. NOTE: Defined in +active_support/core_ext/class/removal.rb+. @@ -663,6 +713,31 @@ See also +Object#remove_subclasses_of+ in "Extensions to All Objects FIX THIS LI NOTE: Defined in +active_support/core_ext/class/removal.rb+. +h4. Reachable Classes + +By definition a non-anonymous class is reachable if its name constantized is defined, and the corresponding constant evaluates to +self+: + +<ruby> +class C; end +C.reachable? # => true + +phantom = Object.send(:remove_const, :C) + +# The class object is orphan now but it still has a name. +phantom.name # => "C" + +# Class name no longer available as a constant. +phantom.reachable? # => nil + +# Let's define a class named "C" again. +class C; end + +# Class name available as a constant, but different class object. +phantom.reachable? # => false +</ruby> + +NOTE: Defined in +active_support/core_ext/class/removal.rb+. + h3. Extensions to +String+ h4. +squish+ diff --git a/railties/guides/source/layout.html.erb b/railties/guides/source/layout.html.erb index eb66366d07..7dfcf4a507 100644 --- a/railties/guides/source/layout.html.erb +++ b/railties/guides/source/layout.html.erb @@ -87,7 +87,7 @@ <div id="container"> <div class="wrapper"> <div id="mainCol"> - <%= yield %> + <%= yield.html_safe! %> </div> </div> </div> |