Exception: Ohm::Model::IndexNotFound

Inherits:
Error show all
Defined in:
lib/ohm.rb

Overview

Raised when you try and do an Set#find operation and use a key which you did not define as an index.

  class Post < Ohm::Model
    attribute :title
  end

  post = Post.create(:title => "Ohm")

  ex = nil
  begin
    Post.find(:title => "Ohm")
  rescue Exception => e
    ex = e
  end

  ex.kind_of?(Ohm::Model::IndexNotFound)
  # => true

To correct this problem, simply define a :title index in your class.

  class Post < Ohm::Model
    attribute :title
    index :title
  end

Instance Method Summary (collapse)

Constructor Details

- (IndexNotFound) initialize(att)

A new instance of IndexNotFound



1034
1035
1036
# File 'lib/ohm.rb', line 1034

def initialize(att)
  @att = att
end

Instance Method Details

- (Object) message



1038
1039
1040
# File 'lib/ohm.rb', line 1038

def message
  "Index #{@att.inspect} not found."
end