Sha256: 9cd7e33cc7a0e7e60d89c48882c6e2b223173da4cc3186dcabe8d3a65315c91b

Contents?: true

Size: 909 Bytes

Versions: 2

Compression:

Stored size: 909 Bytes

Contents

class DSLConfig
  attr_reader :configs, :children, :parent
  def initialize(name, parent = nil, &configs)
    @parent = parent
    @children = []
    @configs = { name: name }
    instance_eval(&configs)
  end

  def method_missing(name, *_params, &configs)
    if block_given?
      @children << DSLConfig.new(name.to_s, self, &configs)
    else
      super
    end
  end

  def respond_to_missing?(_method_name, _include_private)
    #:nocov:
    true
    #:nocov:
  end

  def files(files)
    @configs[:files] = files
  end

  def command(command)
    @configs[:command] = command
  end

  def reversed_exit(reversed_exit)
    @configs[:reversed_exit] = reversed_exit
  end

  def error_message(error_message)
    @configs[:error_message] = error_message
  end

  def success_message(success_message)
    @configs[:success_message] = success_message
  end

  def children?
    !@children.empty?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
renuo-bin-check-1.0.0.beta2 lib/renuo_bin_check/dsl_config.rb
renuo-bin-check-1.0.0.beta1 lib/renuo_bin_check/dsl_config.rb