Class: AppMap::Feature::Function
- Inherits:
-
Base
- Object
- Struct
- FeatureStruct
- Base
- AppMap::Feature::Function
- Defined in:
- lib/appmap/feature.rb
Overview
Function is a feature which represents a code function. It can be an instance function or static (aka ‘class’) function. Instance functions operate on the instance data of the class on which they are defined. Static functions are used to perform operations which don’t have want or need of instance data.
-
‘handler_id` If provided, identifies a trace handler which can apply specialized logic to the event data which is recorded for this function. For example, if the function represents a handler method for a web server, the custom handler can inspect and record the HTTP request method and path info.
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#handler_id ⇒ Object
Returns the value of attribute handler_id.
-
#static ⇒ Object
(also: #static?)
Returns the value of attribute static.
Attributes inherited from Base
Attributes inherited from FeatureStruct
Instance Method Summary collapse
- #instance? ⇒ Boolean
- #to_h ⇒ Object
-
#valid? ⇒ Boolean
Static functions must have an enclosing class defined in order to be traced.
Methods inherited from Base
#add_child, #collect_functions, #enclosing_type_name, #enclosing_type_name?, expand_path, #include_option, #initialize, #prune, #prune?, #remove_child, #reparent, #to_json, #type?
Constructor Details
This class inherits a constructor from AppMap::Feature::Base
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
231 232 233 |
# File 'lib/appmap/feature.rb', line 231 def class_name @class_name end |
#handler_id ⇒ Object
Returns the value of attribute handler_id.
231 232 233 |
# File 'lib/appmap/feature.rb', line 231 def handler_id @handler_id end |
#static ⇒ Object Also known as: static?
Returns the value of attribute static.
231 232 233 |
# File 'lib/appmap/feature.rb', line 231 def static @static end |
Instance Method Details
#instance? ⇒ Boolean
234 235 236 |
# File 'lib/appmap/feature.rb', line 234 def instance? !static? end |
#to_h ⇒ Object
243 244 245 246 247 248 249 |
# File 'lib/appmap/feature.rb', line 243 def to_h super.tap do |h| # Suppress the class name when it can be inferred from the enclosing type. h[:class_name] = class_name if class_name && class_name != enclosing_type_name.join('::') h[:static] = static? end end |
#valid? ⇒ Boolean
Static functions must have an enclosing class defined in order to be traced.
239 240 241 |
# File 'lib/appmap/feature.rb', line 239 def valid? super && (instance? || !class_name.blank?) end |