Module: Kagetsu

Defined in:
lib/kagetsu.rb,
lib/kagetsu/version.rb

Constant Summary collapse

VERSION =
'1.0.0'.freeze

Instance Method Summary collapse

Instance Method Details

#create_or_update(key:, update_attributes:) ⇒ Object



5
6
7
8
9
# File 'lib/kagetsu.rb', line 5

def create_or_update(key:, update_attributes:)
  create_or_update!(key: key, update_attributes: update_attributes)
rescue => ex
  false
end

#create_or_update!(key:, update_attributes:) ⇒ Object



11
12
13
14
# File 'lib/kagetsu.rb', line 11

def create_or_update!(key:, update_attributes:)
  object = find_or_initialize_by(key)
  object.update(update_attributes)
end