require 'kagetsu/version' require 'active_record' module Kagetsu def create_or_update(key:, update_attributes:) create_or_update!(key: key, update_attributes: update_attributes) rescue => ex false end def create_or_update!(key:, update_attributes:) object = find_or_initialize_by(key) object.update(update_attributes) end end ActiveRecord::Base.extend Kagetsu