Sha256: 6fb9140894c429057b8ef366ef73ba18ce93a0a9a26edafcf70e0d44f38c3260
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true require_relative "./condition_pack" require_relative "./condition_creator" require_relative "../logger/logging" module Kanal module Core module Conditions # This class helps in condition pack creation # with the help of dsl class ConditionPackCreator include Logging TEMP_NAME = :temp_name def initialize(name) @name = name @conditions = [] end def create(&block) instance_eval(&block) unless @name logger.fatal "Attempted to create condition pack without name" raise "Please provide condition pack name" end if @conditions.empty? logger.fatal "Attempted to create condition pack #{@name} without conditions provided" raise "Please provide conditions for condition pack #{@name}" end logger.info "Creating condition pack '#{@name}'" pack = ConditionPack.new(@name) @conditions.each do |c| pack.register_condition c end pack end def add_condition(name, &block) creator = ConditionCreator.new name condition = creator.create(&block) @conditions.append condition 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_pack_creator.rb |
kanal-0.4.0 | lib/kanal/core/conditions/condition_pack_creator.rb |