Sha256: d96b111a047dce874f0107f59174e25fae98ec8b9317d78771e35540602092d4

Contents?: true

Size: 681 Bytes

Versions: 21

Compression:

Stored size: 681 Bytes

Contents

class Class #:nodoc:
  def remove_subclasses
    Object.remove_subclasses_of(self)
  end

  def subclasses
    Object.subclasses_of(self).map { |o| o.to_s }
  end

  def remove_class(*klasses)
    klasses.flatten.each do |klass|
      # Skip this class if there is nothing bound to this name
      next unless defined?(klass.name)
      
      basename = klass.to_s.split("::").last
      parent = klass.parent
      
      # Skip this class if it does not match the current one bound to this name
      next unless parent.const_defined?(basename) && klass = parent.const_get(basename)

      parent.instance_eval { remove_const basename } unless parent == klass
    end
  end
end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
activesupport-2.0.0 lib/active_support/core_ext/class/removal.rb
activesupport-2.0.1 lib/active_support/core_ext/class/removal.rb
activesupport-2.0.2 lib/active_support/core_ext/class/removal.rb
activesupport-2.0.4 lib/active_support/core_ext/class/removal.rb
activesupport-2.0.5 lib/active_support/core_ext/class/removal.rb
radiant-0.6.5.1 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
radiant-0.6.5 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
radiant-0.6.7 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
radiant-0.6.6 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
radiant-0.6.8 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
radiant-0.6.9 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
spree-0.0.9 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
spree-0.2.0 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
swivel-0.0.149 vendor/activesupport-2.0.2-/lib/active_support/core_ext/class/removal.rb
swivel-0.0.150 vendor/activesupport-2.0.2-/lib/active_support/core_ext/class/removal.rb
swivel-0.0.156 vendor/activesupport-2.0.2-/lib/active_support/core_ext/class/removal.rb
swivel-0.0.152 vendor/activesupport-2.0.2-/lib/active_support/core_ext/class/removal.rb
swivel-0.0.155 vendor/activesupport-2.0.2-/lib/active_support/core_ext/class/removal.rb
swivel-0.0.160 vendor/activesupport-2.0.2-/lib/active_support/core_ext/class/removal.rb
swivel-0.0.175 vendor/activesupport-2.0.2-/lib/active_support/core_ext/class/removal.rb