Exception: SiteSearch::NoResults

Inherits:
Error
  • Object
show all
Defined in:
lib/site_search/exceptions.rb

Overview

You can rescue from this error in the controller to display the error message provided or the default message

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, query = nil) ⇒ NoResults

Returns a new instance of NoResults.



19
20
21
22
23
# File 'lib/site_search/exceptions.rb', line 19

def initialize(message = nil, query = nil)
  @message = message
  @query = query
  @default_message = "No results for '#{@query}'"
end

Instance Attribute Details

#default_message=(value) ⇒ Object (writeonly)

Sets the attribute default_message

Parameters:

  • value

    the value to set the attribute default_message to.



17
18
19
# File 'lib/site_search/exceptions.rb', line 17

def default_message=(value)
  @default_message = value
end

#queryObject (readonly)

Returns the value of attribute query.



16
17
18
# File 'lib/site_search/exceptions.rb', line 16

def query
  @query
end

Instance Method Details

#to_sObject



25
26
27
# File 'lib/site_search/exceptions.rb', line 25

def to_s
  @message || @default_message
end