class Locomotive::Steam::PageRepository
Public Instance Methods
all(conditions = {})
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 18 def all(conditions = {}) query do where(conditions || {}). order_by(depth: :asc, position: :asc) end.all end
ancestors_of(page)
click to toggle source
Note: Ancestors and self
# File lib/locomotive/steam/repositories/page_repository.rb, line 71 def ancestors_of(page) return [] if page.nil? all(k(:_id, :in) => page.parent_ids + [page._id]) end
by_fullpath(path)
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 43 def by_fullpath(path) first { where(fullpath: path) } end
by_handle(handle)
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 39 def by_handle(handle) first { where(handle: handle) } end
children_of(page)
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 76 def children_of(page) return [] if page.nil? all(parent_id: page._id) end
editable_element_for(page, block, slug)
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 86 def editable_element_for(page, block, slug) return nil if page.nil? || page.editable_elements.nil? page.editable_elements.first do where(block: block, slug: slug) end end
editable_elements_of(page)
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 81 def editable_elements_of(page) return nil if page.nil? page.editable_elements end
matching_fullpath(list)
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 47 def matching_fullpath(list) all(k(:fullpath, :in) => list) end
only_handle_and_fullpath()
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 32 def only_handle_and_fullpath query do where(k(:handle, :ne) => nil). only(:_id, :title, :handle, :fullpath) end.all.tap { mapper.reset_entity_map } end
parent_of(page)
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 65 def parent_of(page) return nil if page.nil? || page.index? first { where(_id: page.parent_id) } end
published()
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 25 def published query do where(published: true). order_by(depth: :asc, position: :asc) end.all end
root()
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 61 def root first { where(fullpath: 'index') } end
template_for(entry, handle = nil)
click to toggle source
# File lib/locomotive/steam/repositories/page_repository.rb, line 51 def template_for(entry, handle = nil) conditions = { templatized: true, target_klass_name: entry.try(:_class_name) } conditions[:handle] = handle if handle all(conditions).first.tap do |page| page.content_entry = entry if page end end