features/pages/page.rb
# return all loaded subclasses in current context by checking new constants/symbols
return all loaded subclasses in current context by checking new constants/symbols
return all loaded subclasses in current context by checking new constants / symbols
def subclasses(desired_superclass)
    remove = [] 
    valid_symbols =
      (Module.constants - remove).select do |possible_subclass|
        (Module.const_get(possible_subclass).is_a? Class) &&
          Module.const_get(possible_subclass).new.is_a?(desired_superclass)
      rescue StandardError
        false
      end
    valid_symbols.map { |subclass_symbol| Module.const_get(subclass_symbol) }
  end
def subclasses ( desired_superclass ) remove = [ ] valid_symbols = ( Module . constants - remove ) . select do | possible_subclass | ( Module . const_get ( possible_subclass ) . is_a? Class ) && Module . const_get ( possible_subclass ) . new . is_a? ( desired_superclass ) rescue StandardError false end valid_symbols . map { | subclass_symbol | Module . const_get ( subclass_symbol ) } end
return all loaded subclasses in current context by checking new constants/symbols
return all loaded subclasses in current context by checking new constants / symbols
# ideally may want to also exclude (all) classes from gems in the gemfile for efficiency # `ruby -e 'require("selenium-webdriver");p Module.constants'`.gsub(/[\[\],:]/, '').split.map(&:to_sym) # Ensure the symbol's a class and, if so, an instance is a subclass
desired_superclass
<not_specific>