Module: WashoutBuilderComplexTypeHelper

Defined in:
app/helpers/washout_builder_complex_type_helper.rb

Overview

module that is used for constructing complex types in HTML-Documentation

Instance Method Summary collapse

Instance Method Details

#create_complex_element_type_html(pre, element, element_description) ⇒ void

This method returns an undefined value.

checks if a complex attribute of a complex type is a array or not and retrieves the complex class name of the attribute and prints it


49
50
51
52
53
54
55
56
# File 'app/helpers/washout_builder_complex_type_helper.rb', line 49

def create_complex_element_type_html(pre, element, element_description)
  complex_class = element.find_complex_class_name
  return if complex_class.nil?
  complex_class_content = element.multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
  pre << "<a href='##{complex_class}'><span class='lightBlue'>#{complex_class_content}</span></a>&nbsp;<span class='bold'>#{element.name}</span>"
  pre << "&#8194;<span>#{html_safe(element_description)}</span>" unless element_description.blank?
  pre
end

#create_element_type_html(pre, element, element_description) ⇒ void

This method returns an undefined value.

this method is for printing the attributes of a complex type if the attributes are primitives this will show the attributes with blue color otherwise will call another method for printing the complex attribute


15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/washout_builder_complex_type_helper.rb', line 15

def create_element_type_html(pre, element, element_description)
  element_description = element_description.blank? ? nil : element_description.fetch(element.name.to_s.downcase, '')
  element.type = 'string' if element.type == 'text'
  element.type = 'integer' if element.type == 'int'
  if WashoutBuilder::Type::BASIC_TYPES.include?(element.type)
    pre << "<span class='blue'>#{element.type}</span>&nbsp;<span class='bold'>#{element.name}</span>"
    pre << "&#8194;<span>#{html_safe(element_description)}</span>" unless element_description.blank?
    pre
  else
    create_complex_element_type_html(pre, element, element_description)
  end
end

#html_safe(string) ⇒ String

used for escaping strings


34
35
36
# File 'app/helpers/washout_builder_complex_type_helper.rb', line 34

def html_safe(string)
  string.present? ? ActiveSupport::SafeBuffer.new(string) : string
end