Class: Miam::DSL::Context

Inherits:
Object
  • Object
show all
Includes:
TemplateHelper
Defined in:
lib/miam/dsl/context.rb

Defined Under Namespace

Classes: Group, ManagedPolicy, Role, User

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TemplateHelper

#context, #include_template

Constructor Details

#initialize(path, options = {}, &block) ⇒ Context

Returns a new instance of Context.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/miam/dsl/context.rb', line 12

def initialize(path, options = {}, &block)
  @path = path
  @options = options
  @result = {:users => {}, :groups => {}, :roles => {}, :instance_profiles => {}, :policies => {}, :exclude => []}

  @context = Hashie::Mash.new(
    :path => path,
    :options => options,
    :templates => {}
  )

  instance_eval(&block)
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



10
11
12
# File 'lib/miam/dsl/context.rb', line 10

def result
  @result
end

Class Method Details

.eval(dsl, path, options = {}) ⇒ Object



4
5
6
7
8
# File 'lib/miam/dsl/context.rb', line 4

def self.eval(dsl, path, options = {})
  self.new(path, options) {
    eval(dsl, binding, path)
  }
end

Instance Method Details

#template(name, &block) ⇒ Object



26
27
28
# File 'lib/miam/dsl/context.rb', line 26

def template(name, &block)
  @context.templates[name.to_s] = block
end