Class: Makwa::Interaction
- Inherits:
-
ActiveInteraction::Base
- Object
- ActiveInteraction::Base
- Makwa::Interaction
- Defined in:
- lib/makwa/interaction.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Interrupt
Instance Method Summary collapse
-
#calling_interaction ⇒ String
The backtrace entry for the immediately calling interaction (first item in calling_interactions).
-
#calling_interactions ⇒ Array<String>
The callstack containing interactions only, starting with the immediate caller.
-
#debug(txt) ⇒ Object
The standard method for all logging output.
-
#id_marker ⇒ String
A marker that identifies an interaction instance by its Ruby object_id.
-
#indent ⇒ String
A prefix that indents each debug line according to the level of interactions nesting.
-
#return_if_errors! ⇒ Object
Exits early if there are any errors.
Instance Method Details
#calling_interaction ⇒ String
Returns the backtrace entry for the immediately calling interaction (first item in calling_interactions).
59 60 61 |
# File 'lib/makwa/interaction.rb', line 59 def calling_interaction @calling_interaction ||= calling_interactions.first&.split("/interactions/")&.last || "" end |
#calling_interactions ⇒ Array<String>
Returns the callstack containing interactions only, starting with the immediate caller.
52 53 54 55 56 |
# File 'lib/makwa/interaction.rb', line 52 def calling_interactions @calling_interactions ||= caller.find_all { |e| e.index("/app/interactions/") && !e.index(__FILE__) && !e.index("/returning_interaction.rb") } end |
#debug(txt) ⇒ Object
The standard method for all logging output. Turn this on for detailed interaction logging.
64 65 66 |
# File 'lib/makwa/interaction.rb', line 64 def debug(txt) # puts indent + txt end |
#id_marker ⇒ String
Returns a marker that identifies an interaction instance by its Ruby object_id. This is helpful when following an execution log with nested or interleaved interaction log lines.
70 71 72 |
# File 'lib/makwa/interaction.rb', line 70 def id_marker "(id##{object_id})" end |
#indent ⇒ String
Returns a prefix that indents each debug line according to the level of interactions nesting.
75 76 77 78 |
# File 'lib/makwa/interaction.rb', line 75 def indent lvl = [0, calling_interactions.count].max " " * lvl end |
#return_if_errors! ⇒ Object
Exits early if there are any errors.
22 23 24 |
# File 'lib/makwa/interaction.rb', line 22 def return_if_errors! raise(Interrupt, errors) if errors_any? end |