Sha256: fcbffa689e86e0ef948c8c2e10170140bda9ce2cc4ac4f1320502726c8b3b9f1

Contents?: true

Size: 673 Bytes

Versions: 9

Compression:

Stored size: 673 Bytes

Contents

# frozen_string_literal: true

module Lite
  module Command
    module Extensions
      module Propagation

        private

        %i[archive destroy save].each do |action|
          define_method("#{action}_and_return!") do |klass|
            merge_errors!(klass) unless klass.send(action)
            klass
          end
        end

        def create_and_return!(klass, params)
          klass = klass.create(params)
          merge_errors!(klass) unless klass.errors.empty?
          klass
        end

        def update_and_return!(klass, params)
          merge_errors!(klass) unless klass.update(params)
          klass
        end

      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lite-command-1.3.2 lib/lite/command/extensions/propagation.rb
lite-command-1.3.1 lib/lite/command/extensions/propagation.rb
lite-command-1.3.0 lib/lite/command/extensions/propagation.rb
lite-command-1.2.0 lib/lite/command/extensions/propagation.rb
lite-command-1.1.1 lib/lite/command/extensions/propagation.rb
lite-command-1.1.0 lib/lite/command/extensions/propagation.rb
lite-command-1.0.10 lib/lite/command/extensions/propagation.rb
lite-command-1.0.9 lib/lite/command/extensions/propagation.rb
lite-command-1.0.8 lib/lite/command/extensions/propagation.rb