Module: WashoutBuilderFaultTypeHelper

Defined in:
app/helpers/washout_builder_fault_type_helper.rb

Overview

method that is used to show that a method can raise a exception in HTML documentation

Instance Method Summary collapse

Instance Method Details

#create_fault_model_complex_element_type(pre, attr_primitive, attribute, array) ⇒ void

This method returns an undefined value.

checks if a complex attribute of a complex type SoapFault is array or not if the attribute is an array will print also the type of the elements contained in the array otherwise will show the complex class of the attribute

Parameters:

  • pre (Array)

    Array that contains the content that will be appended to the xml element li

  • attr_primitive (Class)

    xml li element to which the html will be appended to

  • array (Boolean)

    boolean that is used to know if ia primitive is a array of elements



14
15
16
17
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 14

def create_fault_model_complex_element_type(pre, attr_primitive, attribute, array)
  attribute_primitive = array == true ? "Array of #{attr_primitive}" : "#{attr_primitive}"
  pre << "<a href='##{attr_primitive}'><span class='lightBlue'> #{attribute_primitive}</span></a>&nbsp;<span class='bold'>#{attribute}</span>"
end

#create_html_fault_model_element_type(pre, attribute, attr_details) ⇒ String

this method is used to print all attributes of a SoapFault element if the attribute value is a primitve value it will be shown in blue and will also show the type of the primitive if is a complex type will use another method for finding out the complex class

Parameters:

  • pre (Array)

    Array that contains the content that will be appended to the xml element li

  • attribute (String)

    The name of the attribute that needs to be printed

  • attr_details (Hash)

    hash that contains the member type and determines if the member typs is complex or not

Options Hash (attr_details):

  • :member_type (String)

    The member type of the element ( basic or complex type)

  • :primitive (String)

    the primitive determines if is an array or not

Returns:

  • (String)

    if the primitive is basic or nil , will return the primitive type and the attribute with blue, otherwise will print the complex type and the attribute

See Also:



93
94
95
96
97
98
99
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 93

def create_html_fault_model_element_type(pre, attribute, attr_details)
  if primitive_type_is_basic?(attr_details) || attr_details[:primitive] == 'nilclass'
    pre << "<span class='blue'>#{get_primitive_type_string(attr_details)}</span>&nbsp;<span class='bold'>#{attribute}</span>"
  else
    create_fault_model_complex_element_type(pre, get_member_type_string(attr_details), attribute, true)
  end
end

#get_member_type_string(attr_details) ⇒ String

if the attribute is of type array the method identifies the type of the elements inside the array

@see #member_type_is_basic?

Parameters:

  • attr_details (Hash)

    hash that contains the member type and determines if the member typs is complex or not

Options Hash (attr_details):

  • :member_type (String)

    The member type of the element ( basic or complex type)

  • :primitive (String)

    the primitive determines if is an array or not

Returns:

  • (String)

    if the primitive is array will call another methiod to check the member type otherwise will return the primitive



71
72
73
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 71

def get_member_type_string(attr_details)
  attr_details[:primitive].to_s.downcase == 'array' ? member_type_is_basic?(attr_details) : attr_details[:primitive]
end

#get_primitive_type_string(attr_details) ⇒ String

if the attribute value is of type nil the documentation will show string otherwise the primitive value

Parameters:

  • attr_details (Hash)

    hash that contains the member type and determines if the member typs is complex or not

Options Hash (attr_details):

  • :member_type (String)

    The member type of the element ( basic or complex type)

  • :primitive (String)

    the primitive determines if is an array or not

Returns:

  • (String)

    if the primitive is nilclass will return string , otherwise will return the primitive



56
57
58
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 56

def get_primitive_type_string(attr_details)
  attr_details[:primitive].to_s.downcase == 'nilclass' ? 'string' : attr_details[:primitive].to_s.downcase
end

#member_type_is_basic?(attr_details) ⇒ string

if the attribute is an array this method is used to identify the type of the elements inside the array

Parameters:

  • attr_details (Hash)

    hash that contains the member type and determines if the member typs is complex or not

Options Hash (attr_details):

  • :member_type (String)

    The member type of the element ( basic or complex type)

  • :primitive (String)

    the primitive determines if is an array or not

Returns:

  • (string)

    if the member tyoe is basic will return the type in downcase letter else will return the member type exactly as it is

See Also:



29
30
31
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 29

def member_type_is_basic?(attr_details)
  WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:member_type].to_s.downcase) ? attr_details[:member_type].to_s.downcase : attr_details[:member_type]
end

#primitive_type_is_basic?(attr_details) ⇒ boolean

checks is the attribute has a primitive value or a complex value

Parameters:

  • attr_details (Hash)

    hash that contains the member type and determines if the member typs is complex or not

Options Hash (attr_details):

  • :member_type (String)

    The member type of the element ( basic or complex type)

  • :primitive (String)

    the primitive determines if is an array or not

Returns:

  • (boolean)

See Also:



43
44
45
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 43

def primitive_type_is_basic?(attr_details)
  WashoutBuilder::Type::BASIC_TYPES.include?(attr_details[:primitive].to_s.downcase)
end