Module: NoBrainer::Criteria::FirstOrCreate
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/no_brainer/criteria/first_or_create.rb
Instance Method Summary collapse
- #first_or_create(create_params = {}, save_options = {}, &block) ⇒ Object
- #first_or_create!(create_params = {}, save_options = {}, &block) ⇒ Object
- #upsert(attrs, save_options = {}) ⇒ Object
- #upsert!(attrs, save_options = {}) ⇒ Object
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={}, ={}, &block) _first_or_create(create_params, .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={}, ={}, &block) _first_or_create(create_params, .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, ={}) _upsert(attrs, .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, ={}) _upsert(attrs, .merge(:save_method => :save!, :update => true)) end |