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.



86
87
88
89
90
91
92
93
94
# File 'lib/searchlight/search.rb', line 86

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.



84
85
86
# File 'lib/searchlight/search.rb', line 84

def message
  @message
end

Instance Method Details

#to_sObject



96
97
98
# File 'lib/searchlight/search.rb', line 96

def to_s
  message
end