Class: HolePunch::BaseDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/holepunch/dsl.rb

Direct Known Subclasses

DSL, GroupDSL, ServiceDSL

Instance Method Summary collapse

Constructor Details

#initialize(env, model) ⇒ BaseDSL

Returns a new instance of BaseDSL.



25
26
27
28
# File 'lib/holepunch/dsl.rb', line 25

def initialize(env, model)
  @env = env
  @model = model
end

Instance Method Details

#envObject

Raises:



39
40
41
42
# File 'lib/holepunch/dsl.rb', line 39

def env
  raise EnvNotDefinedError, 'env not defined' if @env.nil?
  @env
end

#eval_dsl(filename = nil, &block) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/holepunch/dsl.rb', line 30

def eval_dsl(filename = nil, &block)
  if !filename.nil?
    instance_eval(HolePunch.read_file(filename.to_s), filename.to_s, 1)
  else
    instance_eval(&block) if block_given?
  end
  @model
end