<commit_before>//
//  JsonApiParentModel.swift
//  VaporJsonApi
//
//  Created by <NAME> on 07/05/2017.
//
//

import Vapor
import Fluent

public struct JsonApiParentModel {

    public typealias JsonApiParentGetter = () throws -> JsonApiResourceModel?
    public typealias JsonApiParentSetter = (_ parent: JsonApiResourceModel) throws -> ()

    public var type: JsonApiResourceModel.Type

    public let getter: JsonApiParentGetter
    public let setter: JsonApiParentSetter?

    public init(parentType: JsonApiResourceModel.Type, getter: @escaping JsonApiParentGetter, setter: JsonApiParentSetter? = nil) {
        self.getter = getter
        self.setter = setter
        self.type = parentType
    }
}<commit_msg>Add temporary initializer for ParentModel. Needs to be checked<commit_after>//
//  JsonApiParentModel.swift
//  VaporJsonApi
//
//  Created by <NAME> on 07/05/2017.
//
//

import Vapor
import Fluent

public struct JsonApiParentModel {

    public typealias JsonApiParentGetter = () throws -> JsonApiResourceModel?
    public typealias JsonApiParentSetter = (_ parent: JsonApiResourceModel) throws -> ()

    public var type: JsonApiResourceModel.Type

    public let getter: JsonApiParentGetter
    public let setter: JsonApiParentSetter?

    public init(parentType: JsonApiResourceModel.Type, getter: @escaping JsonApiParentGetter, setter: JsonApiParentSetter? = nil) {
        self.getter = getter
        self.setter = setter
        self.type = parentType
    }

    public init(model: JsonApiResourceModel, foreignId: Node?, foreignKey: String? = nil, parentType: JsonApiResourceModel.Type, setter: JsonApiParentSetter? = nil) throws {
        self.getter = {
            return try model.parent(foreignId, foreignKey, parentType).get()
        }
        self.setter = setter
        self.type = parentType
    }
}
{'fraction_non_alphanumeric': 0.08809135399673736, 'fraction_numerical': 0.008700380641653072, 'mean_word_length': 3.380952380952381, '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': '2556271', 'n_tokens_mistral': 558, 'n_tokens_neox': 529, 'n_words': 138}