-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2922268
commit 1e244c5
Showing
11 changed files
with
68 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module WashoutBuilderSharedHelper | ||
# 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 | ||
# | ||
# @param [Class, String] complex_class the name of the complex type either as a string or a class | ||
# @return [Class, String] | ||
# @api public | ||
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 | ||
|
||
# Tries to constantize a string or a class to return the class | ||
# | ||
# @param [String] complex_class A string that contains the name of a class | ||
# @return [Class, nil] returns the class if it is classes_defined otherwise nil | ||
# @api public | ||
def find_class_from_string(complex_class) | ||
complex_class.is_a?(Class) ? complex_class : complex_class.constantize | ||
rescue | ||
nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters