Method: Dynamo::Record::Model::ClassMethods#find

Defined in:
lib/dynamo/record/model.rb

#find(opts) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/dynamo/record/model.rb', line 25

def find(opts)
  super(opts).tap do |record|
    unless record
      name = self.name.demodulize
      conditions = opts.map { |k, v| "#{k}=#{v}" }.join(', ')
      error = "Couldn't find #{name} with #{conditions}"
      raise Aws::Record::Errors::NotFound, error
    end
  end
end