Sha256: 2eb40afeb0e859cae7968358b0e7179be701c6ba2500cabe724924ab5db15395

Contents?: true

Size: 578 Bytes

Versions: 4

Compression:

Stored size: 578 Bytes

Contents

module Antelope
  module DSL
    module Contexts
      # The base context, which implements some helper methods.
      class Base
        attr_reader :options

        def initialize(options)
          @options = options
          @contexts = Hash.new { |h, k| h[k] = k.new(@options) }
        end

        def call(&block)
          before_call
          instance_exec(self, &block)
          data
        end

        def context(name, &block)
          @contexts[name].call(&block)
        end

        def before_call; end

        def data; end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
antelope-0.4.1 lib/antelope/dsl/contexts/base.rb
antelope-0.4.0 lib/antelope/dsl/contexts/base.rb
antelope-0.3.2 lib/antelope/dsl/contexts/base.rb
antelope-0.3.0 lib/antelope/dsl/contexts/base.rb