Class: Bosh::Template::EvaluationLink

Inherits:
Object
  • Object
show all
Includes:
PropertyHelper
Defined in:
lib/bosh/template/evaluation_link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PropertyHelper

#copy_property, #lookup_property, #set_property, #sort_property, #validate_properties_format

Constructor Details

#initialize(instances, properties, group_name, group_type, default_network, deployment_name, root_domain, dns_encoder, use_short_dns) ⇒ EvaluationLink

Returns a new instance of EvaluationLink.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bosh/template/evaluation_link.rb', line 11

def initialize(
  instances,
  properties,
  group_name,
  group_type,
  default_network,
  deployment_name,
  root_domain,
  dns_encoder,
  use_short_dns
)
  @instances = instances
  @properties = properties
  @group_name = group_name
  @group_type = group_type
  @default_network = default_network
  @deployment_name = deployment_name
  @root_domain = root_domain
  @dns_encoder = dns_encoder
  @use_short_dns = use_short_dns
end

Instance Attribute Details

#instancesObject (readonly)

Returns the value of attribute instances.



8
9
10
# File 'lib/bosh/template/evaluation_link.rb', line 8

def instances
  @instances
end

#propertiesObject (readonly)

Returns the value of attribute properties.



9
10
11
# File 'lib/bosh/template/evaluation_link.rb', line 9

def properties
  @properties
end

Instance Method Details

#address(criteria = {}) ⇒ Object

Raises:

  • (NotImplementedError)


59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/bosh/template/evaluation_link.rb', line 59

def address(criteria = {})
  raise NotImplementedError, 'link.address requires bosh director' if @dns_encoder.nil?

  full_criteria = criteria.merge(
    group_name: @group_name,
    group_type: @group_type,
    default_network: @default_network,
    deployment_name: @deployment_name,
    root_domain: @root_domain,
  )
  @dns_encoder.encode_query(full_criteria, @use_short_dns)
end

#if_p(*names) {|values| ... } ⇒ Object

Yields:

  • (values)


46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/bosh/template/evaluation_link.rb', line 46

def if_p(*names)
  values = names.map do |name|
    value = lookup_property(@properties, name)
    return Bosh::Template::EvaluationContext::ActiveElseBlock.new(self) if value.nil?

    value
  end

  yield(*values)

  Bosh::Template::EvaluationContext::InactiveElseBlock.new
end

#p(*args) ⇒ Object

Raises:



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bosh/template/evaluation_link.rb', line 33

def p(*args)
  names = Array(args[0])

  names.each do |name|
    result = lookup_property(@properties, name)
    return result unless result.nil?
  end

  return args[1] if args.length == 2

  raise UnknownProperty, names
end