Sha256: 17015d95b54849826ed10722d7a21d0639b5e54e57a5f0dfd7fbcf653366e623
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true require_relative "../logging/logger" module Kanal module Core module Conditions # This class helps creating conditions in dsl way, # with using helper methods class ConditionCreator include Logging::Logger def initialize(name) @name = name @met_block = nil @with_argument = false end def create(&block) logger.debug "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.debug "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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
kanal-0.8.0 | lib/kanal/core/conditions/condition_creator.rb |
kanal-0.7.0 | lib/kanal/core/conditions/condition_creator.rb |
kanal-0.6.0 | lib/kanal/core/conditions/condition_creator.rb |