Sha256: d7c1abe57b5325da49ecb6342f5ef2047e3d2ef33c0ef07a2355808850fdaaa6

Contents?: true

Size: 576 Bytes

Versions: 1

Compression:

Stored size: 576 Bytes

Contents

module Resulang
  class Dsl
    attr_reader :path

    def self.register_section!(section, klass)
      define_section_method(section, klass)
    end

    def initialize(path)
      @path    = path
      @resume = Resume.new
    end

    def resume
      unless @evaluated
        instance_eval(File.read(path))
        @evaluated = true
      end

      @resume
    end

    private

      def self.define_section_method(section, klass)
        define_method(section) do |&block|
          @resume.sections[section.to_sym] = klass.new(&block)
        end
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
resulang-0.0.1 lib/resulang/dsl.rb