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

Commit

Permalink
Adds new EncoderType.encode() function. #8
Browse files Browse the repository at this point in the history
It acceps a `SequenceType` of `Value`. Though to be fair I'm not sure if this would be better as an extension to `SequenceType` instead.
  • Loading branch information
calebd committed Nov 20, 2015
1 parent 7628bff commit 23b444f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Alexander/EncoderType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ public struct NSURLEncoder: EncoderType {
return JSON(object: value.absoluteString)
}
}

extension EncoderType {
public static func encode<S: SequenceType where S.Generator.Element == Value>(sequence: S) -> JSON {
return JSON(object: sequence.map({ encode($0).object }))
}
}

0 comments on commit 23b444f

Please sign in to comment.