Module: Metasploit::ERD::Clusterable

Included in:
Entity::Class, Entity::Namespace
Defined in:
lib/metasploit/erd/clusterable.rb

Overview

Adds #domain and #diagram to any class that responds to #cluster.

Instance Method Summary collapse

Instance Method Details

#diagram(options = {}) ⇒ Metasploit::ERD:Diagram

Diagram using #domain.

Parameters:

  • options (Hash{Symbol => Object}) (defaults to: {})

    options controlling what to include from domain and how to render diagram. Defaults to Diagram::DEFAULT_OPTIONS.

Options Hash (options):

  • :basename (String)

    The basename to use for the :filename option. Only use only if not nil.

  • :diretory (String) — default: Dir.pwd

    The directory to use for the :filename options. Only used if :basename is not nil.

  • :attributes (Array<Symbol>) — default: ATTRIBUTES

    attributes of each entity (table) to include in the diagram.

  • :filetype (String, Symbol) — default: FILETYPE

    the file type of the generated diagram. Supported formats depend on formats supported by graphviz installation.

  • :indirect (Boolean) — default: INDIRECT

    Whether to include indirect (has_many through:) relationships.

  • :inheritance (Boolean) — default: INHERITANCE

    Whether to include Single Table Inheritance (STI) subclass entities.

  • :notation (Symbol) — default: NOTATION

    The cardinality notation to be used. Refer to RailsERD documentation for availble notations.

  • :orientation (:horizontal, :vertical) — default: :horizontal

    The directory of the hierarchy of entities.

  • :polymorphism (Boolean) — default: POLYMORPHISM

    Whether to include abstract or polymorphic pseudo-entities.

  • :title (String)

    Title for diagram.

Returns:

  • (Metasploit::ERD:Diagram)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/metasploit/erd/clusterable.rb', line 13

def diagram(options={})
  merged_options = options.except(:basename, :directory)
  basename = options[:basename]

  if basename
    directory = options[:directory]
    # separate line so coverage can show this case is tested
    directory ||= Dir.pwd

    merged_options[:filename] = File.join(directory, basename)
  end

  Metasploit::ERD::Diagram.new(domain, merged_options)
end

#domainRailsERD::Domain

Domain restricted to #cluster Metasploit::ERD::Cluster#class_set

Returns:

  • (RailsERD::Domain)


31
32
33
34
35
36
37
38
# File 'lib/metasploit/erd/clusterable.rb', line 31

def domain
  RailsERD::Domain.new(
      cluster.class_set,
      # don't warn about missing entities in domain since only belongs_to associations are traced in the cluster and
      # not has_many associations.
      warn: false
  )
end