Class: Mimas::Config::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/mimas/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source = nil, &block) ⇒ DSL

Returns a new instance of DSL.



56
57
58
59
60
61
62
63
64
# File 'lib/mimas/config.rb', line 56

def initialize(source = nil, &block)
  @config = Config.new

  if source
    instance_eval(source)
  else
    instance_exec(&block)
  end
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



54
55
56
# File 'lib/mimas/config.rb', line 54

def config
  @config
end

Instance Method Details

#hooks(&block) ⇒ Object



80
81
82
# File 'lib/mimas/config.rb', line 80

def hooks(&block)
  @config.hooks.instance_exec(&block)
end

#server(name, &block) ⇒ Object



73
74
75
76
77
78
# File 'lib/mimas/config.rb', line 73

def server(name, &block)
  name = name.to_sym
  args = Options.evaluate(&block)
  @config.servers[name] = Mimas::Server.new(name, args)
  @config.servers[name].validate!
end

#site(name = :default, &block) ⇒ Object



66
67
68
69
70
71
# File 'lib/mimas/config.rb', line 66

def site(name = :default, &block)
  name = name.to_sym
  args = Site.evaluate(&block)
  @config.sites[name] = Mimas::Site.new(name, args)
  @config.sites[name].validate!
end