Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/post/hwbridge/object_aliases.rb
Views: 11783
# -*- coding: binary -*-12module Rex3module Post4module HWBridge56###7#8# Mixin for classes that wish to have object aliases but do not9# really need to inherit from the ObjectAliases class.10#11###12module ObjectAliasesContainer1314#15# Initialize the instance's aliases.16#17def initialize_aliases(aliases = {})18self.aliases = aliases19end2021#22# Pass-thru aliases.23#24def method_missing(symbol, *args)25self.aliases[symbol.to_s]26end2728#29# Recursively dumps all of the aliases registered with a class that30# is kind_of? ObjectAliases.31#32def dump_alias_tree(parent_path, current = nil)33items = []3435if (current == nil)36current = self37end3839# If the current object may have object aliases...40if (current.kind_of?(Rex::Post::HWBridge::ObjectAliases))41current.aliases.each_key { |x|42current_path = parent_path + '.' + x4344items << current_path4546items.concat(dump_alias_tree(current_path,47current.aliases[x]))48}49end5051return items52end5354#55# The hash of aliases.56#57attr_accessor :aliases58end5960###61#62# Generic object aliases from a class instance referenced symbol to an63# associated object of an arbitrary type64#65###66class ObjectAliases67include Rex::Post::HWBridge::ObjectAliasesContainer6869##70#71# Constructor72#73##7475# An instance76def initialize(aliases = {})77initialize_aliases(aliases)78end79end808182end; end; end838485