require_dependency 'theme' class Theme class << self def approved_themes(owner) Dir.glob(File.join(system_themes_dir, '*')).map do |item| next unless File.exists? File.join(item, 'theme.yml') id = File.basename item config = YAML.load_file File.join(item, 'theme.yml') approved = config['public'] unless approved begin approved = owner.kind_of?(config['owner_type'].constantize) rescue end approved &&= config['owner_id'] == owner.id if config['owner_id'].present? end approved = false if id == 'cube-responsive' [id, config] if approved end.compact.map do |id, config| new id, config end end end end