Sha256: 28e586914a53f20d06556faa9a70fbb0091ad7553b7d128f788df5f162ace0c8
Contents?: true
Size: 887 Bytes
Versions: 2
Compression:
Stored size: 887 Bytes
Contents
# frozen_string_literal: true module Lite module Command module Extensions module Propagation private def assign_and_return!(instance, params) instance.assign_attributes(params) errors.merge!(instance.errors) unless instance.valid? instance end def create_and_return!(klass, params) klass = klass.create(params) merge_errors!(klass) unless klass.errors.empty? klass end def update_and_return!(instance, params) merge_errors!(instance) unless instance.update(params) instance end %i[archive destroy save].each do |action| define_method("#{action}_and_return!") do |instance| merge_errors!(instance) unless instance.send(action) instance end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lite-command-1.5.0 | lib/lite/command/extensions/propagation.rb |
lite-command-1.4.1 | lib/lite/command/extensions/propagation.rb |