Class: Searchlight::Search::UndefinedOption

Inherits:
Error
  • Object
show all
Defined in:
lib/searchlight/search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(option_name, search) ⇒ UndefinedOption

Returns a new instance of UndefinedOption.



93
94
95
96
97
98
99
100
101
# File 'lib/searchlight/search.rb', line 93

def initialize(option_name, search)
  option_name = option_name.to_s.sub(/=\Z/, '')
  self.message = "#{search.class.name} doesn't search '#{option_name}' or have an accessor for that property."
  if option_name.start_with?('search_')
    method_maybe_intended = option_name.sub(/\Asearch_/, '')
    # Gee golly, I'm so helpful!
    self.message << " Did you just mean '#{method_maybe_intended}'?" if search.respond_to?("#{method_maybe_intended}=")
  end
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



91
92
93
# File 'lib/searchlight/search.rb', line 91

def message
  @message
end

Instance Method Details

#to_sObject



103
104
105
# File 'lib/searchlight/search.rb', line 103

def to_s
  message
end