Class: Msf::DataStoreWithFallbacks::DataStoreSearchResult
- Inherits:
-
Object
- Object
- Msf::DataStoreWithFallbacks::DataStoreSearchResult
- 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
-
#fallback_key ⇒ String?
readonly
The key associated with the fallback value.
-
#namespace ⇒ Symbol
readonly
protected
Namespace Where the search result was found, i.e.
-
#result ⇒ Symbol
readonly
protected
Result is one of ‘user_defined`, `not_found`, `option_fallback`, `option_default`, `imported_default`.
-
#value ⇒ object?
readonly
The value if found.
Instance Method Summary collapse
- #default? ⇒ Boolean
- #fallback? ⇒ Boolean
- #found? ⇒ Boolean
- #global? ⇒ Boolean
-
#initialize(result, value, namespace: nil, fallback_key: nil) ⇒ DataStoreSearchResult
constructor
A new instance of DataStoreSearchResult.
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_key ⇒ String? (readonly)
Returns 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 |
#namespace ⇒ Symbol (readonly, protected)
Returns 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 |
#result ⇒ Symbol (readonly, protected)
Returns 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 |
#value ⇒ object? (readonly)
Returns 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
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
525 526 527 |
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 525 def fallback? result == :option_fallback end |
#found? ⇒ Boolean
521 522 523 |
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 521 def found? result != :not_found end |
#global? ⇒ Boolean
529 530 531 |
# File 'lib/msf/core/data_store_with_fallbacks.rb', line 529 def global? namespace == :global_data_store && found? end |