Module: WashoutBuilderSharedHelper
- Included in:
- WashoutBuilderComplexTypeHelper, WashoutBuilderMethodArgumentsHelper, WashoutBuilderMethodListHelper, WashoutBuilderMethodReturnTypeHelper
- Defined in:
- app/helpers/washout_builder_shared_helper.rb
Instance Method Summary collapse
-
#find_class_from_string(complex_class) ⇒ Class?
Tries to constantize a string or a class to return the class.
-
#find_correct_complex_type(complex_class) ⇒ Class, String
When displaying a complex type that inherits from WashOut::Type we must use its descendant name to properly show the correct Type that can we used to make the actual request to the action.
Instance Method Details
#find_class_from_string(complex_class) ⇒ Class?
Tries to constantize a string or a class to return the class
24 25 26 27 28 |
# File 'app/helpers/washout_builder_shared_helper.rb', line 24 def find_class_from_string(complex_class) complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil end |
#find_correct_complex_type(complex_class) ⇒ Class, String
When displaying a complex type that inherits from WashOut::Type we must use its descendant name to properly show the correct Type that can we used to make the actual request to the action
9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/washout_builder_shared_helper.rb', line 9 def find_correct_complex_type(complex_class) real_class = find_class_from_string(complex_class) if real_class.present? && real_class.ancestors.include?( WashoutBuilder::Type.base_type_class) descendant = WashoutBuilder::Type.base_param_class.parse_def(config, real_class.wash_out_param_map)[0] descendant.find_complex_class_name else complex_class end end |