Class: Posgra::DSL::Database::Role

Inherits:
Object
  • Object
show all
Includes:
Logger::Helper, TemplateHelper, Utils::Helper
Defined in:
lib/posgra/dsl/database/role.rb

Defined Under Namespace

Classes: Database

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Helper

#matched?

Methods included from TemplateHelper

#context, #include_template

Methods included from Logger::Helper

#log

Constructor Details

#initialize(context, role, options, &block) ⇒ Role

Returns a new instance of Role.



8
9
10
11
12
13
14
# File 'lib/posgra/dsl/database/role.rb', line 8

def initialize(context, role, options, &block)
  @role = role
  @options = options
  @context = context.merge(:role => role)
  @result = {}
  instance_eval(&block)
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



6
7
8
# File 'lib/posgra/dsl/database/role.rb', line 6

def result
  @result
end

Instance Method Details

#database(name, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/posgra/dsl/database/role.rb', line 16

def database(name, &block)
  name = name.to_s

  if matched?(name, @options[:include_database], @options[:exclude_database])
    @result[name] = Posgra::DSL::Database::Role::Database.new(@context, name, @options, &block).result
  end
end