Class: Ferret::Browser::DocumentController

Inherits:
Controller
  • Object
show all
Defined in:
lib/ferret/browser.rb

Constant Summary

Constants inherited from Controller

Controller::APP_DIR, Controller::STATIC_DIR

Instance Method Summary collapse

Methods inherited from Controller

#initialize, #method_missing

Methods included from ViewHelper

#tick_or_cross, #truncate

Constructor Details

This class inherits a constructor from Ferret::Browser::Controller

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ferret::Browser::Controller

Instance Method Details

#list(page = 0) ⇒ Object Also known as: index



184
185
186
187
188
189
190
# File 'lib/ferret/browser.rb', line 184

def list(page = 0)
  @page = (page||0).to_i
  @page_size = @params[:page_size]||10
  @first = @page * @page_size
  @last = [@reader.max_doc, (@page + 1) * @page_size].min
  render(:action => :list)
end

#show(doc_id) ⇒ Object



193
194
195
196
197
198
199
200
201
# File 'lib/ferret/browser.rb', line 193

def show(doc_id)
  doc_id = @params['doc_id']||doc_id||'0'
  if doc_id !~ /^\d+$/
    raise ArgumentError.new("invalid document number '#{doc_id}'")
  end
  @doc_id = doc_id.to_i
  @doc = @reader[@doc_id].load unless @reader.deleted?(@doc_id)
  render(:action => :show)
end