Sha256: 1adcbeb41ae63b61baa8f042dfe5b1fa43f65fa5a63902f5f2c72bdf465699f8

Contents?: true

Size: 676 Bytes

Versions: 86

Compression:

Stored size: 676 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.send :remove_const, basename unless parent == klass
    end
  end
end

Version data entries

86 entries across 86 versions & 8 rubygems

Version Path
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
jstorimer-deep-test-1.3.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
jstorimer-deep-test-1.2.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
jstorimer-deep-test-1.1.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
jstorimer-deep-test-1.0.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
jstorimer-deep-test-0.2.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
jstorimer-deep-test-0.1.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
activesupport-1.3.1 lib/active_support/core_ext/class/removal.rb
activesupport-1.4.1 lib/active_support/core_ext/class/removal.rb
activesupport-1.4.0 lib/active_support/core_ext/class/removal.rb
activesupport-1.4.4 lib/active_support/core_ext/class/removal.rb
activesupport-1.3.0 lib/active_support/core_ext/class/removal.rb
activesupport-1.4.2 lib/active_support/core_ext/class/removal.rb
activesupport-1.4.3 lib/active_support/core_ext/class/removal.rb
backlog-0.0.0 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
backlog-0.0.1 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
backlog-0.0.2 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
backlog-0.0.5 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb
backlog-0.0.4 vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb