Sha256: c1199686b2a9a36e2d90eaf0577f8fc2d9171e81f25bac5e35a45215f65b7403

Contents?: true

Size: 467 Bytes

Versions: 7

Compression:

Stored size: 467 Bytes

Contents

# frozen_string_literal: true

module Macros
  class Model
    # Persist object from the context
    # @example
    #   step Macros::Model::Persist(ctx_key: :weekly_plan_editing)
    class Persist < Macros::Base
      def initialize(ctx_key: :model, method: :save!)
        @ctx_key = ctx_key
        @method = method
      end

      def call(ctx, **)
        return false unless ctx[@ctx_key]

        ctx[@ctx_key].public_send(@method)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ff-tbl-macros-2.0.2 lib/macros/model/persist.rb
ff-tbl-macros-2.0.1 lib/macros/model/persist.rb
ff-tbl-macros-2.0.0 lib/macros/model/persist.rb
ff-tbl-macros-1.0.2 lib/macros/model/persist.rb
ff-tbl-macros-1.0.1 lib/macros/model/persist.rb
ff-tbl-macros-1.0.0 lib/macros/model/persist.rb
ff-tbl-macros-0.1.8 lib/macros/model/persist.rb