Module: NoBrainer::Criteria::FirstOrCreate

Extended by:
ActiveSupport::Concern
Defined in:
lib/no_brainer/criteria/first_or_create.rb

Instance Method Summary collapse

Instance Method Details

#first_or_create(create_params = {}, save_options = {}, &block) ⇒ Object



4
5
6
# File 'lib/no_brainer/criteria/first_or_create.rb', line 4

def first_or_create(create_params={}, save_options={}, &block)
  _first_or_create(create_params, save_options.merge(:save_method => :save?), &block)
end

#first_or_create!(create_params = {}, save_options = {}, &block) ⇒ Object



8
9
10
# File 'lib/no_brainer/criteria/first_or_create.rb', line 8

def first_or_create!(create_params={}, save_options={}, &block)
  _first_or_create(create_params, save_options.merge(:save_method => :save!), &block)
end

#upsert(attrs, save_options = {}) ⇒ Object



12
13
14
# File 'lib/no_brainer/criteria/first_or_create.rb', line 12

def upsert(attrs, save_options={})
  _upsert(attrs, save_options.merge(:save_method => :save?, :update => true))
end

#upsert!(attrs, save_options = {}) ⇒ Object



16
17
18
# File 'lib/no_brainer/criteria/first_or_create.rb', line 16

def upsert!(attrs, save_options={})
  _upsert(attrs, save_options.merge(:save_method => :save!, :update => true))
end