<commit_before>module BubbleWrap
  module Message

    module_function

    # Base method to create your in-app mail
    # ---------------------------------------
    # EX
    #   BW::Message.compose {
    #     delegate: self, # optional, will use root view controller by default
    #     to: [ "1(234)567-8910" ],
    #     message: "This is my message. It isn't very long.",
    #     animated: false
    #   } do |result, error|
    #     result.sent?      # => boolean
    #     result.canceled?  # => boolean
    #     result.failed?    # => boolean
    #     error             # => NSError
    #   end
    def compose(options={}, &callback)
      @delegate = options[:delegate] || App.window.rootViewController
      @callback = callback
      @message_controller = create_message_controller(options)
      @message_is_animated = options[:animated] == false ? false : true
      @delegate.presentModalViewController(@message_controller, animated: @mailer_is_animated)
    end
    
    def create_message_controller(options={})
      message_controller = MFMessageComposeViewController.alloc.init
      message_controller.messageComposeDelegate = self
      message_controller.body = options[:message] 
      message_controller.recipients = Array(options[:to])     
      message_controller
    end

    # Event when the MFMessageComposeViewController is closed
    # -------------------------------------------------------------
    # the callback is fired if it was present in the constructor

    def messageComposeViewController(controller, didFinishWithResult: result)
      @delegate.dismissModalViewControllerAnimated(@message_is_animated)
      @callback.call Result.new(result) if @callback
    end
  end
end<commit_msg>bug fix<commit_after>module BubbleWrap
  module Message

    module_function

    # Base method to create your in-app mail
    # ---------------------------------------
    # EX
    # BW::Message.compose (
    # {
    #   delegate: self, # optional, will use root view controller by default
    #   to: [ "1(234)567-8910" ],
    #   message: "This is my message. It isn't very long.",
    #   animated: false
    # }) {|result, error|
    #   result.sent?      # => boolean
    #   result.canceled?  # => boolean
    #   result.failed?    # => boolean
    #   error             # => NSError
    #   }           
  
    def compose(options={}, &callback)
      @delegate = options[:delegate] || App.window.rootViewController
      @callback = callback
      @message_controller = create_message_controller(options)
      @message_is_animated = options[:animated] == false ? false : true
      @delegate.presentModalViewController(@message_controller, animated: @message_is_animated)
    end
    
    def create_message_controller(options={})
      message_controller = MFMessageComposeViewController.alloc.init
      message_controller.messageComposeDelegate = self
      message_controller.body = options[:message] 
      message_controller.recipients = Array(options[:to])     
      message_controller
    end

    # Event when the MFMessageComposeViewController is closed
    # -------------------------------------------------------------
    # the callback is fired if it was present in the constructor

    def messageComposeViewController(controller, didFinishWithResult: result)
      @delegate.dismissModalViewControllerAnimated(@message_is_animated)
      @callback.call Result.new(result) if @callback
    end
  end
end
{'fraction_non_alphanumeric': 0.14223889209463358, 'fraction_numerical': 0.006347374495095211, 'mean_word_length': 2.34975845410628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5254306', 'n_tokens_mistral': 936, 'n_tokens_neox': 887, 'n_words': 216}