Module: AppMap::Feature
- Defined in:
- lib/appmap/feature.rb
Overview
A Feature is a construct within the code that will be observed. Examples features include modules, classes and functions.
Defined Under Namespace
Classes: Base, Cls, FeatureStruct, Function, Package
Constant Summary collapse
- TYPE_MAP =
{ 'cls' => 'class' }.freeze
- FEATURE_BUILDERS =
{ module: ->(_) { Module.new }, class: ->(_) { Cls.new }, function: lambda do |hash| static = hash.delete('static') class_name = hash.delete('class_name') Function.new.tap do |e| e.static = static e.class_name = class_name end end }.freeze
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Deserialize a feature from a Hash.
Class Method Details
.from_hash(hash) ⇒ Object
Deserialize a feature from a Hash. The Hash is typically a deserialized JSON dump of the feature.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/appmap/feature.rb', line 24 def from_hash(hash) builder = FEATURE_BUILDERS[hash['type'].to_sym] raise "Unrecognized type of feature: #{type.inspect}" unless builder feature = builder.call(hash) feature.name = hash['name'] feature.location = hash['location'] feature.attributes = hash['attributes'] || {} feature.children = (hash['children'] || []).map { |child| from_hash(child) } feature end |