Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop' of https://github.com/Alecrim/AlecrimCoreData
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
vmartinelli committed Oct 18, 2016
2 parents c333d39 + af45292 commit 4cdb803
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions Source/AlecrimCoreData/Core/Protocols/CoreDataQueryable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,31 @@ extension CoreDataQueryable {

public final func sum<U>(_ closure: (Self.Element.Type) -> Attribute<U>) -> U {
let attribute = closure(Self.Element.self)
return self.aggregate(using: "sum", attribute: attribute)
return self.aggregate(withFunctionName: "sum", attribute: attribute)
}

public final func min<U>(_ closure: (Self.Element.Type) -> Attribute<U>) -> U {
let attribute = closure(Self.Element.self)
return self.aggregate(using: "min", attribute: attribute)
return self.aggregate(withFunctionName: "min", attribute: attribute)
}

public final func max<U>(_ closure: (Self.Element.Type) -> Attribute<U>) -> U {
let attribute = closure(Self.Element.self)
return self.aggregate(using: "max", attribute: attribute)
return self.aggregate(withFunctionName: "max", attribute: attribute)
}

// same as average, for convenience
public final func avg<U>(_ closure: (Self.Element.Type) -> Attribute<U>) -> U {
let attribute = closure(Self.Element.self)
return self.aggregate(using: "average", attribute: attribute)
return self.aggregate(withFunctionName: "average", attribute: attribute)
}

public final func average<U>(_ closure: (Self.Element.Type) -> Attribute<U>) -> U {
let attribute = closure(Self.Element.self)
return self.aggregate(using: "average", attribute: attribute)
return self.aggregate(withFunctionName: "average", attribute: attribute)
}

private final func aggregate<U>(using functionName: String, attribute: Attribute<U>) -> U {
private final func aggregate<U>(withFunctionName functionName: String, attribute: Attribute<U>) -> U {
let attributeDescription = self.entityDescription.attributesByName[attribute.___name]!

let keyPathExpression = NSExpression(forKeyPath: attribute.___name)
Expand Down
2 changes: 1 addition & 1 deletion Source/AlecrimCoreData/Core/Protocols/TableProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension TableProtocol {
objectIDs = try fetchRequest.execute()
}
else {
objectIDs = try! self.context.fetch(fetchRequest)
objectIDs = try self.context.fetch(fetchRequest)
}

for objectID in objectIDs {
Expand Down

0 comments on commit 4cdb803

Please sign in to comment.