<commit_before>module DiabeticToolbox
  rely_on :result

  # = Action
  #
  # Action is the base for each action taken in the Diabetic Toolbox.  When
  # a class defined which inherits from Action, the child is required at minimum
  # to redefine +_call+ which carries out the necessary work to perform the action.
  #
  # The following is a brief example
  #
  #   class MyAction < Action
  #     def initialize(params)
  #       super params
  #     end
  #
  #     protected
  #     def _call
  #       # ...
  #     end
  #   end
  #
  # If there is some necessary preparation to do before the call is made,
  # you should implement +_before_call+ as follows:
  #
  #   protected
  #   def _before_call
  #     # ...
  #   end
  #
  # And similarly when there is work to be performed after the call,
  # +_after_call+ should be defined:
  #
  #   protected
  #   def _after_call
  #     # ...
  #   end
  class Action
    #:enddoc:

    #region Public
    def initialize(params)
      @params  = params
      @result  = nil
    end

    def call
      _before_call
      _call
      _after_call
      @result
    end
    #endregion

    #region Protected
    protected
    def success(&block)
      @result = Result.success &block
    end

    def failure(&block)
      @result = Result.failure &block
    end

    def _call ; end

    def _before_call ; end

    def _after_call ; end<commit_msg>A result method to allow actions to internally recognize if the action has succeeded or failed (intended for use within _after_call as work would likely be dependent on this)<commit_after>module DiabeticToolbox
  rely_on :result

  # = Action
  #
  # Action is the base for each action taken in the Diabetic Toolbox.  When
  # a class defined which inherits from Action, the child is required at minimum
  # to redefine +_call+ which carries out the necessary work to perform the action.
  #
  # The following is a brief example
  #
  #   class MyAction < Action
  #     def initialize(params)
  #       super params
  #     end
  #
  #     protected
  #     def _call
  #       # ...
  #     end
  #   end
  #
  # If there is some necessary preparation to do before the call is made,
  # you should implement +_before_call+ as follows:
  #
  #   protected
  #   def _before_call
  #     # ...
  #   end
  #
  # And similarly when there is work to be performed after the call,
  # +_after_call+ should be defined:
  #
  #   protected
  #   def _after_call
  #     # ...
  #   end
  class Action
    #:enddoc:

    #region Public
    def initialize(params)
      @params  = params
      @result  = nil
    end

    def call
      _before_call
      _call
      _after_call
      @result
    end
    #endregion

    #region Protected
    protected
    def result
      @result
    end

    def success(&block)
      @result = Result.success &block
    end

    def failure(&block)
      @result = Result.failure &block
    end

    def _call ; end

    def _before_call ; end

    def _after_call ; end
{'fraction_non_alphanumeric': 0.06564478507164279, 'fraction_numerical': 0.0, 'mean_word_length': 2.088477366255144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1351794', 'n_tokens_mistral': 928, 'n_tokens_neox': 904, 'n_words': 331}