Module: DTK::DSL::Template::Generation::Mixin

Included in:
DTK::DSL::Template
Defined in:
lib/dsl/template/generation/mixin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filterObject (readonly)

Returns the value of attribute filter.



32
33
34
# File 'lib/dsl/template/generation/mixin.rb', line 32

def filter
  @filter
end

#topObject (readonly)

Returns the value of attribute top.



32
33
34
# File 'lib/dsl/template/generation/mixin.rb', line 32

def top
  @top
end

Instance Method Details

#generate!Object

Main template-specific generate call; Concrete classes overwrite this



23
24
25
# File 'lib/dsl/template/generation/mixin.rb', line 23

def generate!
  raise Error::NoMethodForConcreteClass.new(self.class)
end

#generate?Boolean

This is overwritten if template can conditionally generate elements

Returns:

  • (Boolean)


28
29
30
# File 'lib/dsl/template/generation/mixin.rb', line 28

def generate?
  generate!
end

#generate_yaml_file_path__content_array(top_file_path) ⇒ Object

Array where each element has keys :path and :content



67
68
69
70
# File 'lib/dsl/template/generation/mixin.rb', line 67

def generate_yaml_file_path__content_array(top_file_path)
  self.generate!
  [{ :path => top_file_path, :content => YamlHelper.generate(@yaml_object) }] + generate_nested_dsl_file_path__content_array
end

#generate_yaml_objectObject



56
57
58
59
# File 'lib/dsl/template/generation/mixin.rb', line 56

def generate_yaml_object
  generate!
  @yaml_object
end

#generate_yaml_object?Boolean

generate_yaml_object? can be ovewritten

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/dsl/template/generation/mixin.rb', line 51

def generate_yaml_object?
  generate?
  is_empty?(@yaml_object) ? nil : @yaml_object
end

#generate_yaml_textObject



61
62
63
64
# File 'lib/dsl/template/generation/mixin.rb', line 61

def generate_yaml_text
  self.generate!
  YamlHelper.generate(@yaml_object)
end

#yaml_object_typeObject

The methods yaml_object_type can be set on concrete class; it wil be set if input and output types are different



74
75
76
# File 'lib/dsl/template/generation/mixin.rb', line 74

def yaml_object_type
  nil
end