Class: Fig::Statement::Configuration

Inherits:
Fig::Statement show all
Defined in:
lib/fig/statement/configuration.rb

Overview

A grouping of statements within a package. May not be nested.

Any processing of statements is guaranteed to hit any Overrides first.

Constant Summary

Constants inherited from Fig::Statement

ENVIRONMENT_VARIABLE_NAME_REGEX

Instance Attribute Summary collapse

Attributes inherited from Fig::Statement

#column, #line, #source_description

Instance Method Summary collapse

Methods inherited from Fig::Statement

#is_asset?, position_description, #position_string, #urls

Constructor Details

#initialize(line_column, source_description, name, statements) ⇒ Configuration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fig/statement/configuration.rb', line 12

def initialize(line_column, source_description, name, statements)
  super(line_column, source_description)

  @name = name

  overrides, others = statements.partition do
    |statement| statement.is_a?(Fig::Statement::Override)
  end

  @statements = [overrides, others].flatten
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/fig/statement/configuration.rb', line 10

def name
  @name
end

#statementsObject (readonly)

Returns the value of attribute statements.



10
11
12
# File 'lib/fig/statement/configuration.rb', line 10

def statements
  @statements
end

Instance Method Details

#command_statementObject



24
25
26
27
28
# File 'lib/fig/statement/configuration.rb', line 24

def command_statement
  return statements.find do
    |statement| statement.is_a?(Fig::Statement::Command)
  end
end

#unparse(indent) ⇒ Object



38
39
40
# File 'lib/fig/statement/configuration.rb', line 38

def unparse(indent)
  unparse_statements(indent, "config #{@name}", @statements, 'end')
end

#walk_statements(&block) ⇒ Object

Block will receive a Statement.



31
32
33
34
35
36
# File 'lib/fig/statement/configuration.rb', line 31

def walk_statements(&block)
  @statements.each do |statement|
    yield statement
    statement.walk_statements &block
  end
end