Class: Refinery::Pages::Finder::FinderByPathOrId

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

Instance Method Summary collapse

Constructor Details

#initialize(path, id) ⇒ FinderByPathOrId

Returns a new instance of FinderByPathOrId.



156
157
158
159
# File 'pages/lib/refinery/pages/finder.rb', line 156

def initialize(path, id)
  @path = path
  @id = id
end

Instance Method Details

#findObject



161
162
163
164
165
166
167
168
169
170
171
# File 'pages/lib/refinery/pages/finder.rb', line 161

def find
  if path.present?
    if path.friendly_id?
      FinderByPath.new(path).find
    else
      Page.friendly.find(path)
    end
  elsif id.present?
    Page.friendly.find(id)
  end
end