Class: MarkdownExec::HashDelegator

Inherits:
HashDelegatorParent show all
Defined in:
lib/hash_delegator.rb

Instance Attribute Summary

Attributes inherited from HashDelegatorParent

#most_recent_loaded_filename, #p_all_arguments, #p_options_parsed, #p_params, #p_rest, #pass_args, #run_state

Class Method Summary collapse

Methods inherited from HashDelegatorParent

#absolute_path, #add_menu_chrome_blocks!, #append_chrome_block, #append_divider, #append_inherited_lines, #apply_block_type_color_option, #apply_tree_decorations, #assign_key_value_in_bash, #block_state_for_name_from_cli, #blocks_find_by_block_name, #blocks_from_nested_files, #calc_logged_stdout_filename, #cfile, #check_file_existence, #code_from_vars_block_to_set_environment_variables, #collect_line_decor_patterns, #command_execute, #command_execute_in_own_window, #command_execute_in_own_window_format_arguments, #command_execute_in_process, #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?, #dml_menu_append_chrome_item, #do_save_execution_output, #document_name_in_glob_as_file_name, #dump_and_warn_block_state, #dump_delobj, #edit_text, #execute_block_by_type_for_lfls, #execute_block_for_state_and_name, #execute_block_in_state, #execute_block_type_history_ux, #execute_block_type_link_with_state, #execute_block_type_load_code_lines, #execute_block_type_port_code_lines, #execute_block_type_save, #execute_command_with_streams, #execute_history_select, #execute_inherited_save, #execute_navigate_back, #execute_required_lines, #fetch_color, #file_info, #format_and_execute_command, #format_expression, #format_references_send_color, #formatted_expression, #fout_execution_report, #generate_temp_filename, #handle_back_or_continue, #handle_stream, #history_files, #initial_state, #initialize, #iter_blocks_from_nested_files, #iter_source_blocks, #link_block_data_eval, #link_history_push_and_next, #link_load_format_data, #list_blocks, #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_add_disabled_option, #menu_chrome_colored_option, #menu_chrome_formatted_option, #method_missing, #next_state_append_code, #next_state_set_code, #output_color_formatted, #output_execution_summary, #output_labeled_value, #pause_user_exit, #pop_add_current_code_to_head_and_trigger_load, #pop_link_history_new_state, #post_execution_process, #prepare_blocks_menu, #print_formatted_option, #process_string_array, #prompt_approve_repeat, #prompt_for_command, #prompt_for_filespec_with_wildcard, #prompt_for_user_approval, #prompt_select_code_filename, #prompt_select_continue, #prompt_user_exit, #publish_for_external_automation, #puts_gets_oprompt_, #read_saved_assets_for_history_table, #read_show_options_and_trigger_reuse, #register_console_attributes, #report_error, #respond_to?, #runtime_exception, #save_filespec_from_expression, #save_filespec_wildcard_expansion, #save_to_file, #saved_asset_filename, #saved_asset_for_history, #select_document_if_multiple, #select_option_with_metadata, #shell, #shell=, #shell_escape_asset_format, #should_add_back_option?, #simple_menu_options, #start_fenced_block, #string_send_color, #update_line_and_block_state, #update_menu_base, #variable_expansions!, #vux_await_user_selection, #vux_clear_menu_state, #vux_edit_inherited, #vux_execute_and_prompt, #vux_execute_block_per_type, #vux_formatted_names_for_state_chrome_blocks, #vux_history_files_table_rows, #vux_init, #vux_input_and_execute_shell_commands, #vux_load_code_files_into_state, #vux_load_inherited, #vux_main_loop, #vux_menu_append_history_files, #vux_navigate_back_for_ls, #vux_parse_document, #vux_publish_block_name_for_external_automation, #vux_publish_document_file_name_for_external_automation, #vux_user_selected_block_name, #vux_view_inherited, #wait_for_stream_processing, #wait_for_user_selected_block, #wait_for_user_selection, #write_command_file, #write_file_with_directory_creation, #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, #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, #tables_into_columns!, #tty_prompt_without_disabled_symbol, #update_menu_attrib_yield_selected, #yield_line_if_selected

Methods included from TextAnalyzer

analyze_hierarchy, highlight_segments, yield_matches_and_non_matches

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 hash or struct from unwanted values.



4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
# File 'lib/hash_delegator.rb', line 4171

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.reject! do |_key, value|
      [nil, '', [], {}, nil].include?(value)
    end
  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.



4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
# File 'lib/hash_delegator.rb', line 4156

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
    clean_hash_recursively(struct_hash) # Clean the hash
    # Return the cleaned hash instead of updating the Struct

  else
    value
  end
end


4186
4187
4188
# File 'lib/hash_delegator.rb', line 4186

def self.next_link_state(*args, **kwargs, &block)
  super
end