Class: Refinery::Pages::Finder

Inherits:
Object
  • Object
show all
Defined in:
pages/lib/refinery/pages/finder.rb

Direct Known Subclasses

FinderBySlug, FinderByTitle

Defined Under Namespace

Classes: FinderByPath, FinderByPathOrId, FinderByScopedPath, FinderBySlug, FinderByTitle, FinderByUnscopedPath

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conditions) ⇒ Finder

Returns a new instance of Finder.



24
25
26
# File 'pages/lib/refinery/pages/finder.rb', line 24

def initialize(conditions)
  @conditions = conditions
end

Class Method Details

.by_path(path) ⇒ Object



4
5
6
# File 'pages/lib/refinery/pages/finder.rb', line 4

def self.by_path(path)
  FinderByPath.new(path).find
end

.by_path_or_id(path, id) ⇒ Object



8
9
10
# File 'pages/lib/refinery/pages/finder.rb', line 8

def self.by_path_or_id(path, id)
  FinderByPathOrId.new(path, id).find
end

.by_slug(slug, conditions = {}) ⇒ Object



16
17
18
# File 'pages/lib/refinery/pages/finder.rb', line 16

def self.by_slug(slug, conditions = {})
  FinderBySlug.new(slug, conditions).find
end

.by_title(title) ⇒ Object



12
13
14
# File 'pages/lib/refinery/pages/finder.rb', line 12

def self.by_title(title)
  FinderByTitle.new(title).find
end

.with_mobility(conditions = {}) ⇒ Object



20
21
22
# File 'pages/lib/refinery/pages/finder.rb', line 20

def self.with_mobility(conditions = {})
  Finder.new(conditions).find
end

Instance Method Details

#findObject



28
29
30
# File 'pages/lib/refinery/pages/finder.rb', line 28

def find
  with_mobility
end

#with_mobilityObject



32
33
34
35
36
37
38
39
40
41
# File 'pages/lib/refinery/pages/finder.rb', line 32

def with_mobility
  mobility_conditions = {:locale => ::Mobility.locale.to_s}.merge(conditions)
  translations_conditions = translations_conditions(mobility_conditions)

  # A join implies readonly which we don't really want.
  Page.i18n.where(mobility_conditions).
       joins(:translations).
       where(translations_conditions).
       readonly(false)
end