Module: TypeStation::Concerns::PathGenerator::ClassMethods

Defined in:
lib/type_station/concerns/path_generator.rb

Instance Method Summary collapse

Instance Method Details

#find_by_path(path) ⇒ Object



31
32
33
34
35
# File 'lib/type_station/concerns/path_generator.rb', line 31

def find_by_path(path)
  search_path = File.join('',path)
  pages = self.or({path: search_path}, {:old_paths.in  => [search_path]}).to_a
  pages.select {|p| p.path == search_path}.first.presence || pages.select {|p| p.old_paths.include?(search_path) }.first
end