Class: TemplateInput

Inherits:
ApplicationRecord show all
Includes:
Exportable
Defined in:
app/models/template_input.rb

Defined Under Namespace

Classes: UnsatisfiedRequiredInput, ValueNotReady

Constant Summary collapse

VALUE_TYPE =
['plain', 'search', 'date']

Instance Method Summary collapse

Methods included from Exportable

#export_attr, #export_iterable

Methods inherited from ApplicationRecord

graphql_type, #logger, logger

Methods included from AuditAssociations::AssociationsDefinitions

#audit_associations, #audited, #configure_dirty_associations, #normalize_associations

Instance Method Details

#basic?Boolean

Returns:

  • (Boolean)

69
70
71
# File 'app/models/template_input.rb', line 69

def basic?
  !advanced
end

#fact_template_input?Boolean

Returns:

  • (Boolean)

42
43
44
45
# File 'app/models/template_input.rb', line 42

def fact_template_input?
  Foreman::Deprecation.deprecation_warning('2.5', 'use #input_type or #input_type_instance to determine input type')
  input_type == 'fact'
end

#input_type_instanceObject


33
34
35
# File 'app/models/template_input.rb', line 33

def input_type_instance
  Foreman.input_types_registry.get(input_type).new if input_type
end

#options_arrayObject


65
66
67
# File 'app/models/template_input.rb', line 65

def options_array
  options.blank? ? [] : options.split(/\r?\n/).map(&:strip)
end

#preview(scope) ⇒ Object


57
58
59
# File 'app/models/template_input.rb', line 57

def preview(scope)
  resolver(scope).preview
end

#puppet_parameter_template_input?Boolean

Returns:

  • (Boolean)

52
53
54
55
# File 'app/models/template_input.rb', line 52

def puppet_parameter_template_input?
  Foreman::Deprecation.deprecation_warning('2.5', 'use #input_type or #input_type_instance to determine input type')
  input_type == 'puppet_parameter'
end

#to_export(include_blank = true) ⇒ Object


14
15
16
17
18
# File 'app/models/template_input.rb', line 14

def to_export(include_blank = true)
  hash_to_export = super
  additions = input_type_instance.additional_to_export(self, include_blank)
  hash_to_export.merge(additions.stringify_keys)
end

#user_template_input?Boolean

Returns:

  • (Boolean)

37
38
39
40
# File 'app/models/template_input.rb', line 37

def user_template_input?
  Foreman::Deprecation.deprecation_warning('2.5', 'use #input_type or #input_type_instance to determine input type')
  input_type == 'user'
end

#value(scope) ⇒ Object


61
62
63
# File 'app/models/template_input.rb', line 61

def value(scope)
  resolver(scope).value
end

#variable_template_input?Boolean

Returns:

  • (Boolean)

47
48
49
50
# File 'app/models/template_input.rb', line 47

def variable_template_input?
  Foreman::Deprecation.deprecation_warning('2.5', 'use #input_type or #input_type_instance to determine input type')
  input_type == 'variable'
end