Sha256: 9a418d63d0948c3f76e69483d55cc3e7528e44a0202c14bef6f8fa99fb882448

Contents?: true

Size: 600 Bytes

Versions: 6

Compression:

Stored size: 600 Bytes

Contents

module Compositor
  class DSL
    attr_reader :context
    attr_accessor :generator

    def initialize(context)
      @context = context
    end

    def self.create(context, &block)
      dsl = new(context)
      context.instance_variables.each do |variable|
        dsl.instance_variable_set(variable, context.instance_variable_get(variable))
      end
      dsl.instance_eval &block if block
      dsl
    end

    def to_json(options = {})
      generator.to_json(options)
    end

    def to_hash
      if generator
        generator.to_hash
      else
        nil
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
compositor-2.0.1 lib/compositor/dsl.rb
compositor-2.0.0 lib/compositor/dsl.rb
compositor-1.0.1 lib/compositor/dsl.rb
compositor-1.0.0 lib/compositor/dsl.rb
compositor-0.1.4 lib/compositor/dsl.rb
compositor-0.1.3 lib/compositor/dsl.rb