Module: ActiveMocker::ActiveHash::ARApi::ClassMethods

Includes:
ActiveHash::ARApi::DestroyAll, ActiveHash::ARApi::FindBy
Defined in:
lib/active_hash/ar_api.rb

Instance Method Summary collapse

Methods included from ActiveHash::ARApi::FindBy

#find_by, #find_by!, #where

Methods included from ActiveHash::ARApi::DestroyAll

#destroy_all

Instance Method Details

#find_or_create_by(attributes) ⇒ Object



21
22
23
# File 'lib/active_hash/ar_api.rb', line 21

def find_or_create_by(attributes)
  find_by(attributes) || create(attributes)
end

#find_or_initialize_by(attributes) ⇒ Object



25
26
27
# File 'lib/active_hash/ar_api.rb', line 25

def find_or_initialize_by(attributes)
  find_by(attributes) || new(attributes)
end