<commit_before>//
//  NSManagedObjectExtensions.swift
//  AlecrimCoreData
//
//  Created by <NAME> on 2014-06-24.
//  Copyright (c) 2014 Alecrim. All rights reserved.
//

import Foundation
import CoreData

extension NSManagedObject {
    
    public func inContext(context: Context) -> Self? {
        return self.inManagedObjectContext(context.managedObjectContext)
    }
    
}

extension NSManagedObject {
    
    private func inManagedObjectContext(otherManagedObjectContext: NSManagedObjectContext) -> Self? {
        if self.managedObjectContext == otherManagedObjectContext {
            return self
        }
        
        var error: NSError? = nil
        if self.objectID.temporaryID {
            if let moc = self.managedObjectContext {
                let success = moc.obtainPermanentIDsForObjects([self as NSManagedObject], error: &error)
                if !success {
                    return nil
                }
            }
            else {
                return nil<commit_msg>Turned public inManagedObjectContext extension method<commit_after>//
//  NSManagedObjectExtensions.swift
//  AlecrimCoreData
//
//  Created by <NAME> on 2014-06-24.
//  Copyright (c) 2014 Alecrim. All rights reserved.
//

import Foundation
import CoreData

extension NSManagedObject {
    
    public func inContext(context: Context) -> Self? {
        return self.inManagedObjectContext(context.managedObjectContext)
    }
    
    public func inManagedObjectContext(otherManagedObjectContext: NSManagedObjectContext) -> Self? {
        if self.managedObjectContext == otherManagedObjectContext {
            return self
        }
        
        var error: NSError? = nil
        if self.objectID.temporaryID {
            if let moc = self.managedObjectContext {
                let success = moc.obtainPermanentIDsForObjects([self as NSManagedObject], error: &error)
                if !success {
                    return nil
                }
            }
            else {
                return nil
{'fraction_non_alphanumeric': 0.07528479445269935, 'fraction_numerical': 0.01188707280832095, 'mean_word_length': 2.0559757942511347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7058272', 'n_tokens_mistral': 546, 'n_tokens_neox': 513, 'n_words': 129}