Class: Msf::DataStoreWithFallbacks::DataStoreSearchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/msf/core/data_store_with_fallbacks.rb

Overview

Simple dataclass for storing the result of a datastore search

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, value, namespace: nil, fallback_key: nil) ⇒ DataStoreSearchResult

Returns a new instance of DataStoreSearchResult.



510
511
512
513
514
515
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 510

def initialize(result, value, namespace: nil, fallback_key: nil)
  @namespace = namespace
  @result = result
  @value = value
  @fallback_key = fallback_key
end

Instance Attribute Details

#fallback_keyString? (readonly)

Returns the key associated with the fallback value.

Returns:

  • (String, nil)

    the key associated with the fallback value



505
506
507
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 505

def fallback_key
  @fallback_key
end

#namespaceSymbol (readonly, protected)

Returns namespace Where the search result was found, i.e. a module datastore or global datastore.

Returns:

  • (Symbol)

    namespace Where the search result was found, i.e. a module datastore or global datastore



536
537
538
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 536

def namespace
  @namespace
end

#resultSymbol (readonly, protected)

Returns result is one of ‘user_defined`, `not_found`, `option_fallback`, `option_default`, `imported_default`.

Returns:

  • (Symbol)

    result is one of 'user_defined`, `not_found`, `option_fallback`, `option_default`, `imported_default`



539
540
541
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 539

def result
  @result
end

#valueobject? (readonly)

Returns The value if found.

Returns:

  • (object, nil)

    The value if found



508
509
510
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 508

def value
  @value
end

Instance Method Details

#default?Boolean

Returns:

  • (Boolean)


517
518
519
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 517

def default?
  result == :imported_default || result == :option_default || !found?
end

#fallback?Boolean

Returns:

  • (Boolean)


525
526
527
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 525

def fallback?
  result == :option_fallback
end

#found?Boolean

Returns:

  • (Boolean)


521
522
523
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 521

def found?
  result != :not_found
end

#global?Boolean

Returns:

  • (Boolean)


529
530
531
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 529

def global?
  namespace == :global_data_store && found?
end