Sha256: cbc3c8990e96c63881d346868416816d5aee6ada7f9ad7ca187022d308bd3f6b
Contents?: true
Size: 870 Bytes
Versions: 9
Compression:
Stored size: 870 Bytes
Contents
module Rasti class App class Utils class << self def classes_in(namespace, superclass=nil) [].tap do |classes| namespace.constants.each do |name| constant = namespace.const_get name if constant.class == Module classes_in(constant, superclass).each { |c| classes << c } elsif constant.class == Class && (superclass.nil? || constant.ancestors.include?(superclass)) classes << constant end end end end def namespace_of(klass) namespace = klass.name.split('::')[0..-2].join('::') namespace.empty? ? nil : Object.const_get(namespace) end def split_hash(hash, keys) [hash.slice(*keys), hash.slice(*(hash.keys - keys))] end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems