Sha256: 88296cad487477181883293e3d90c91d92805125aa7130d758df644a18973c8f
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require_relative "../logger/logging" module Kanal module Core module Conditions # This class helps creating conditions in dsl way, # with using helper methods class ConditionCreator include Logging def initialize(name) @name = name @met_block = nil @with_argument = false end def create(&block) logger.info "Attempting to create condition '#{@name}'" instance_eval(&block) unless @name logger.fatal "Attempted to create condition without name" raise "Please provide name for condition" end unless @met_block logger.fatal "Attempted to create condition without met block" raise "Please provide met? block for condition #{@name}" end logger.info "Creating condition '#{@name}'" Condition.new @name, with_argument: @with_argument, &@met_block end def with_argument @with_argument = true end def met?(&block) @met_block = block end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kanal-0.4.1 | lib/kanal/core/conditions/condition_creator.rb |
kanal-0.4.0 | lib/kanal/core/conditions/condition_creator.rb |