<commit_before>//
//  UITableView+Additions.swift
//  TableViewTools
//
//  Created by <NAME> on 09/12/2016.
//  Copyright © 2016 Rosberry. All rights reserved.
//

import UIKit.UITableView

public enum ReuseType {
    case byStoryboard(identifier: String)
    case byNib(nib: UINib, identifier: String)
    case byClass(cellClass: UITableViewCell.Type, identifier: String)
    
    public var identifier: String {
        switch self {
        case let .byStoryboard(identifier): return identifier
        case let .byNib(_, identifier: identifier): return identifier
        case let .byClass(cellClass: _, identifier: identifier): return identifier
        }
    }
    
    public init(cellClass: UITableViewCell.Type) {
        self = .byClass(cellClass: cellClass, identifier: NSStringFromClass(cellClass))
    }
}

public extension UITableView {
    
    func register(by type: ReuseType) {
        switch type {
        case let .byNib(nib: nib, identifier: identifier):
            register(nib, forCellReuseIdentifier: identifier)
        case let .byClass(cellClass: cellClass, identifier: identifier):
            register(cellClass, forCellReuseIdentifier: identifier)
        default: break
        }
    }
    
    func dequeueReusableCell<T: UITableViewCell>() -> T {
        return dequeueReusableCell(withIdentifier: NSStringFromClass(T.self)) as! T
    }
    
    /// Calls `beginUpdates()` before execution of closure in parameter and `endUpdates()` after
    ///
    /// - Parameter closure: a closure with insertions, deletions or selections operations in `UITableView`
    func update(_ closure: (() -> Void)) {
        beginUpdates()
        closure()
        endUpdates()
    }
}<commit_msg>Refactore `UITableView+Additions`<commit_after>//
//  UITableView+Additions.swift
//  TableViewTools
//
//  Created by <NAME> on 09/12/2016.
//  Copyright © 2016 Rosberry. All rights reserved.
//

import UIKit.UITableView

public enum ReuseType {
    case byStoryboardIdentifier(String)
    case byNib(UINib, identifier: String)
    case byClass(UITableViewCell.Type, identifier: String)
    
    public var identifier: String {
        switch self {
        case let .byStoryboardIdentifier(identifier):   return identifier
        case let .byNib(_, identifier: identifier):     return identifier
        case let .byClass(_, identifier: identifier):   return identifier
        }
    }
    
    public init(cellClass: UITableViewCell.Type) {
        self = .byClass(cellClass, identifier: NSStringFromClass(cellClass))
    }
}

public extension UITableView {
    
    func register(by type: ReuseType) {
        switch type {
        case let .byNib(nib, identifier: identifier):          register(nib, forCellReuseIdentifier: identifier)
        case let .byClass(cellClass, identifier: identifier):  register(cellClass, forCellReuseIdentifier: identifier)
        default: break
        }
    }
    
    func dequeueReusableCell<T: UITableViewCell>() -> T {
        return dequeueReusableCell(withIdentifier: NSStringFromClass(T.self)) as! T
    }
    
    /// Calls `beginUpdates()` before execution of closure in parameter and `endUpdates()` after
    ///
    /// - Parameter closure: a closure with insertions, deletions or selections operations in `UITableView`
    func update(_ closure: (() -> Void)) {
        beginUpdates()
        closure()
        endUpdates()
    }
}
{'fraction_non_alphanumeric': 0.09770453207769277, 'fraction_numerical': 0.007062978222483814, 'mean_word_length': 2.840677966101695, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4033974', 'n_tokens_mistral': 1005, 'n_tokens_neox': 926, 'n_words': 263}