Module: ActiveHash::ARApi::FindBy

Included in:
ActiveMocker::ActiveHash::ARApi::ClassMethods
Defined in:
lib/active_hash/find_by.rb

Instance Method Summary collapse

Instance Method Details

#find_by(options = {}) ⇒ Object



8
9
10
# File 'lib/active_hash/find_by.rb', line 8

def find_by(options = {})
  send(:where, options).first
end

#find_by!(options = {}) ⇒ Object

Raises:

  • (ActiveRecord::RecordNotFound)


12
13
14
15
16
# File 'lib/active_hash/find_by.rb', line 12

def find_by!(options={})
  result = find_by(options)
  raise ActiveRecord::RecordNotFound if result.blank?
  result
end