Class: MarkdownExec::HashDelegator
- Inherits:
-
HashDelegatorParent
- Object
- HashDelegatorParent
- MarkdownExec::HashDelegator
- Defined in:
- lib/hash_delegator.rb
Instance Attribute Summary
Attributes inherited from HashDelegatorParent
#most_recent_loaded_filename, #pass_args, #run_state
Class Method Summary collapse
-
.clean_hash_recursively(obj) ⇒ Object
Recursively cleans the given object (hash or struct) from unwanted values.
-
.clean_value(value) ⇒ Object
Cleans a value, handling both Hash and Struct types.
- .next_link_state(*args, **kwargs, &block) ⇒ Object
Methods inherited from HashDelegatorParent
#add_menu_chrome_blocks!, #append_chrome_block, #append_divider, #append_inherited_lines, #apply_shell_color_option, #assign_key_value_in_bash, #block_state_for_name_from_cli, #blocks_from_nested_files, #calc_logged_stdout_filename, #cfile, #check_file_existence, #collect_required_code_lines, #command_execute, #compile_execute_and_trigger_reuse, #contains_wildcards?, #copy_to_clipboard, #count_blocks_in_filename, #create_and_add_chrome_block, #create_and_add_chrome_blocks, #create_divider, #debounce_allows, #debounce_reset, #determine_block_state, #display_required_code, #divider_formatting_present?, #do_save_execution_output, #document_menu_loop, #dump_and_warn_block_state, #dump_delobj, #exec_bash_next_state, #execute_required_lines, #execute_shell_type, #fetch_color, #format_and_execute_command, #format_expression, #format_multiline_body_as_title, #format_references_send_color, #formatted_expression, #get_block_summary, #handle_back_or_continue, #handle_stream, #ii_execute_block, #ii_parse_document, #ii_user_choice, #initial_state, #initialize, #iter_blocks_from_nested_files, #link_block_data_eval, #link_history_push_and_next, #link_load_format_data, #load_auto_opts_block, #load_cli_or_user_selected_block, #load_filespec_from_expression, #load_filespec_wildcard_expansion, #manage_cli_selection_state, #mdoc_and_blocks_from_nested_files, #mdoc_menu_and_blocks_from_nested_files, #menu_chrome_colored_option, #menu_chrome_formatted_option, #method_missing, #output_color_formatted, #output_execution_result, #output_execution_summary, #output_labeled_value, #pop_add_current_code_to_head_and_trigger_load, #pop_link_history_and_trigger_load, #post_execution_process, #prepare_blocks_menu, #print_formatted_option, #process_block_based_on_type, #process_string_array, #prompt_approve_repeat, #prompt_for_filespec_with_wildcard, #prompt_for_user_approval, #prompt_select_code_filename, #prompt_select_continue, #prompt_user_exit, #push_link_history_and_trigger_load, #puts_gets_oprompt_, #read_show_options_and_trigger_reuse, #runtime_exception, #save_filespec_from_expression, #save_filespec_wildcard_expansion, #save_to_file, #select_option_with_metadata, #set_delob_filename_block_name, #set_delobj_menu_loop_vars, #set_environment_variables_for_block, #should_add_back_option?, #start_fenced_block, #string_send_color, #update_line_and_block_state, #wait_for_stream_processing, #wait_for_user_selected_block, #wait_for_user_selection, #write_command_file, #write_inherited_lines_to_file
Methods included from HashDelegatorSelf
#apply_color_from_hash, #block_find, #code_merge, #count_matches_in_lines, #create_directory_for_file, #create_file_and_write_string_with_permissions, #default_block_title_from_body, #delete_consecutive_blank_lines!, #error_handler, #format_execution_streams, #indent_all_lines, #initialize_fcb_names, #join_code_lines, #merge_lists, #next_link_state, #parse_yaml_data_from_body, #read_required_blocks_from_temp_file, #remove_file_without_standard_errors, #safeval, #set_file_permissions, #tty_prompt_without_disabled_symbol, #update_menu_attrib_yield_selected, #write_execution_output_to_file, #yield_line_if_selected
Methods included from CompactionHelpers
#compact_and_convert_array_to_hash, #compact_and_index_hash, #compact_hash
Constructor Details
This class inherits a constructor from MarkdownExec::HashDelegatorParent
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class MarkdownExec::HashDelegatorParent
Class Method Details
.clean_hash_recursively(obj) ⇒ Object
Recursively cleans the given object (hash or struct) from unwanted values.
2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 |
# File 'lib/hash_delegator.rb', line 2399 def self.clean_hash_recursively(obj) obj.each do |key, value| cleaned_value = clean_value(value) # Clean and possibly convert value obj[key] = cleaned_value if value.is_a?(Hash) || value.is_a?(Struct) end if obj.is_a?(Hash) obj.select! { |key, value| ![nil, '', [], {}, nil].include?(value) } end obj end |
.clean_value(value) ⇒ Object
Cleans a value, handling both Hash and Struct types. For Structs, the cleaned version is converted to a hash.
2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 |
# File 'lib/hash_delegator.rb', line 2384 def self.clean_value(value) case value when Hash clean_hash_recursively(value) when Struct struct_hash = value.to_h # Convert the Struct to a hash cleaned_hash = clean_hash_recursively(struct_hash) # Clean the hash # Return the cleaned hash instead of updating the Struct return cleaned_hash else value end end |
.next_link_state(*args, **kwargs, &block) ⇒ Object
2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 |
# File 'lib/hash_delegator.rb', line 2412 def self.next_link_state(*args, **kwargs, &block) super # result = super # @logger ||= StdOutErrLogger.new # @logger.unknown( # HashDelegator.clean_hash_recursively( # { "HashDelegator.next_link_state": # { 'args': args, # 'at': Time.now.strftime('%FT%TZ'), # 'for': /[^\/]+:\d+/.match(caller.first)[0], # 'kwargs': kwargs, # 'return': result } } # ) # ) # result end |