Sha256: 1a6d419fb8e1341a5a61008ecbe672b10433f92ae7c2036b645f9ef7e507e1e2
Contents?: true
Size: 1.96 KB
Versions: 5
Compression:
Stored size: 1.96 KB
Contents
# frozen_string_literal: true module ConvenientService module Service module Plugins module HasResultSteps module Entities class Method module Commands class DefineMethodInContainer < Support::Command include Support::Delegate attr_reader :method, :container, :index delegate :key, :name, to: :method def initialize(method:, container:, index:) @method = method @container = container @index = index end def call ## # NOTE: Assignement in the beginning for easier debugging. # <<~RUBY.tap { |code| container.klass.class_eval(code, __FILE__, __LINE__ + 1) } def #{name} step, key, method_name = steps[#{index}], :#{key}, :#{name} raise #{not_completed_step_error}.new(step: step, method_name: method_name) unless step.completed? raise #{not_existing_step_result_data_attribute_error}.new(step: step, key: key) unless step.result.unsafe_data.has_attribute?(key) step.result.unsafe_data[key] end RUBY true end private def not_completed_step_error <<~RUBY.chomp ::ConvenientService::Service::Plugins::HasResultSteps::Entities::Method::Errors::NotCompletedStep RUBY end def not_existing_step_result_data_attribute_error <<~RUBY.chomp ::ConvenientService::Service::Plugins::HasResultSteps::Entities::Method::Errors::NotExistingStepResultDataAttribute RUBY end end end end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems