Exception: Lycra::UndefinedIndexError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/lycra/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document = nil) ⇒ UndefinedIndexError

Returns a new instance of UndefinedIndexError.



50
51
52
53
54
55
56
57
58
# File 'lib/lycra/errors.rb', line 50

def initialize(document=nil)
  @document = document

  if document.nil?
    super("You must define an index_name for your document class. Try: `index_name 'my-searchable-things'`")
  else
    super("You must define an index_name for your #{document.class.name}. Try: `index_name '#{subject_name.underscore.pluralize}'`")
  end
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



48
49
50
# File 'lib/lycra/errors.rb', line 48

def document
  @document
end

Instance Method Details

#subject_nameObject



60
61
62
63
64
65
66
# File 'lib/lycra/errors.rb', line 60

def subject_name
  if document.subject.is_a?(Class)
    document.subject.name
  else
    document.subject.class.name
  end
end