Class: Locomotive::Steam::PageFinderService

Inherits:
Object
  • Object
show all
Includes:
Services::Concerns::Decorator
Defined in:
lib/locomotive/steam/services/page_finder_service.rb

Direct Known Subclasses

ParentFinderService

Instance Method Summary collapse

Instance Method Details

#by_handle(handle, with_cache = true) ⇒ Object



27
28
29
30
31
# File 'lib/locomotive/steam/services/page_finder_service.rb', line 27

def by_handle(handle, with_cache = true)
  decorate do
    with_cache ? page_map[handle] : repository.by_handle(handle)
  end
end

#find(path) ⇒ Object



10
11
12
13
14
# File 'lib/locomotive/steam/services/page_finder_service.rb', line 10

def find(path)
  decorate do
    repository.by_fullpath(path)
  end
end

#find_by_id(id) ⇒ Object



33
34
35
36
37
# File 'lib/locomotive/steam/services/page_finder_service.rb', line 33

def find_by_id(id)
  decorate do
    repository.find(id)
  end
end

#match(path) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/locomotive/steam/services/page_finder_service.rb', line 16

def match(path)
  decorate do
    repository.matching_fullpath(path_combinations(path))
  end.sort do |page_1, page_2|
    # normal pages have priority over the templatized ones if they're not in the same "folder"
    same_folder?(page_1, page_2) ?
      page_1.position <=> page_2.position :
      (page_2.fullpath.include?(WILDCARD) ? 0 : 1) <=> (page_1.fullpath.include?(WILDCARD) ? 0 : 1)
  end
end