Class: Transpec::DynamicAnalyzer::RuntimeData
- Inherits:
-
Object
- Object
- Transpec::DynamicAnalyzer::RuntimeData
show all
- Includes:
- NodeUtil
- Defined in:
- lib/transpec/dynamic_analyzer/runtime_data.rb
Defined Under Namespace
Classes: CompatibleOpenStruct
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from NodeUtil
#node_id
Constructor Details
#initialize(data = CompatibleOpenStruct.new) ⇒ RuntimeData
Returns a new instance of RuntimeData.
20
21
22
|
# File 'lib/transpec/dynamic_analyzer/runtime_data.rb', line 20
def initialize(data = CompatibleOpenStruct.new)
@data = data
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
12
13
14
|
# File 'lib/transpec/dynamic_analyzer/runtime_data.rb', line 12
def data
@data
end
|
Class Method Details
.load(string_or_io) ⇒ Object
14
15
16
17
18
|
# File 'lib/transpec/dynamic_analyzer/runtime_data.rb', line 14
def self.load(string_or_io)
options = { object_class: CompatibleOpenStruct, symbolize_names: true }
data = JSON.load(string_or_io, nil, options)
new(data)
end
|
Instance Method Details
#[](node, key = nil) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/transpec/dynamic_analyzer/runtime_data.rb', line 24
def [](node, key = nil)
node_data = data[node_id(node)]
return nil unless node_data
return node_data unless key
node_data[key]
end
|
#present?(node, key) ⇒ Boolean
35
36
37
38
39
|
# File 'lib/transpec/dynamic_analyzer/runtime_data.rb', line 35
def present?(node, key)
node_data = self[node]
return false unless node_data
node_data.respond_to?(key)
end
|
#run?(node) ⇒ Boolean
31
32
33
|
# File 'lib/transpec/dynamic_analyzer/runtime_data.rb', line 31
def run?(node)
self[node]
end
|