Class: Refinery::Pages::FinderByPathOrId

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

Instance Method Summary collapse

Constructor Details

#initialize(path, id) ⇒ FinderByPathOrId

Returns a new instance of FinderByPathOrId.



158
159
160
161
# File 'lib/refinery/pages/finder.rb', line 158

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

Instance Method Details

#findObject



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

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