Module: WashoutBuilderFaultTypeHelper

Defined in:
app/helpers/washout_builder_fault_type_helper.rb

Instance Method Summary collapse

Instance Method Details

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



3
4
5
6
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 3

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) ⇒ Object



25
26
27
28
29
30
31
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 25

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) ⇒ Object



21
22
23
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 21

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) ⇒ Object



17
18
19
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 17

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) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/helpers/washout_builder_fault_type_helper.rb', line 9

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

Returns:

  • (Boolean)


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

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