<commit_before>module ProMotion
  module TableViewCellModule
    include ViewHelper

    attr_accessor :data_cell

    def setup(data_cell)
      self.data_cell = data_cell

      # TODO: Some of these need to go away. Unnecessary overhead.
      set_cell_attributes
      set_background_color
      set_class_attributes
      set_accessory_view
      set_subtitle
      set_image
      set_remote_image
      set_subviews
      set_details
      set_styles
      set_selection_style

      self
    end

    def set_cell_attributes
      set_attributes self, data_cell.dup.tap{ |h| h.delete(:image) }
      self
    end

    def set_background_color
      self.backgroundView = UIView.new.tap{|v| v.backgroundColor = data_cell[:background_color]} if data_cell[:background_color]
    end

    def set_class_attributes
      if data_cell[:cell_class_attributes]
        PM.logger.deprecated "`cell_class_attributes` is deprecated. Just add the attributes you want to set right into your cell hash."
        set_attributes self, data_cell[:cell_class_attributes]
      end
      self
    end

    def set_accessory_view
      data_cell[:accessory] ||= data_cell[:accessory_view]

      if data_cell[:accessory] == :switch
        switch_view = UISwitch.alloc.initWithFrame(CGRectZero)
        switch_view.addTarget(cell_table_view, action: "accessory_toggled_switch:", forControlEvents:UIControlEventValueChanged)
        switch_view.on = true if data_cell[:accessory_checked]<commit_msg>Fix accessory_action crash.<commit_after>module ProMotion
  module TableViewCellModule
    include ViewHelper

    attr_accessor :data_cell

    def setup(data_cell)
      self.data_cell = data_cell

      # TODO: Some of these need to go away. Unnecessary overhead.
      set_cell_attributes
      set_background_color
      set_class_attributes
      set_accessory_view
      set_subtitle
      set_image
      set_remote_image
      set_subviews
      set_details
      set_styles
      set_selection_style

      self
    end

    def set_cell_attributes
      data_cell_attributes = data_cell.dup
      [:image, :accessory_action].each { |k| data_cell_attributes.delete(k) }
      set_attributes self, data_cell_attributes
      self
    end

    def set_background_color
      self.backgroundView = UIView.new.tap{|v| v.backgroundColor = data_cell[:background_color]} if data_cell[:background_color]
    end

    def set_class_attributes
      if data_cell[:cell_class_attributes]
        PM.logger.deprecated "`cell_class_attributes` is deprecated. Just add the attributes you want to set right into your cell hash."
        set_attributes self, data_cell[:cell_class_attributes]
      end
      self
    end

    def set_accessory_view
      data_cell[:accessory] ||= data_cell[:accessory_view]

      if data_cell[:accessory] == :switch
        switch_view = UISwitch.alloc.initWithFrame(CGRectZero)
        switch_view.addTarget(cell_table_view, action: "accessory_toggled_switch:", forControlEvents:UIControlEventValueChanged)
        switch_view.on = true if data_cell[:accessory_checked]
{'fraction_non_alphanumeric': 0.059624108878807515, 'fraction_numerical': 0.0, 'mean_word_length': 3.275623268698061, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7586066', 'n_tokens_mistral': 924, 'n_tokens_neox': 894, 'n_words': 199}