 
     let registrar: Registrar
 
+    /**
+     Initialize the capability. By default, it requires no extra application permissions.
+
+     Note that framework consumers should not initialized this class directly, but instead
+     use Capability.Cloud, which is a typealias of CloudCapability, and has a slightly 
+     different initializer to allow supplying the CloudKit container identifier.
+
+     - see: Capability.Cloud
+     - see: CloudCapability
+
+     - parameter requirement: the required EKEntityType, defaults to .Event
+     - parameter registrar: the registrar to use. Defauls to creating a Registrar.
+     */
     public required init(_ requirement: CKApplicationPermissions = [], registrar: Registrar = Registrar()) {
         self.name = "Cloud"
         self.requirement = requirement


}

public class CloudCapability<Registrar: CloudContainerRegistrarType>: _CloudCapability<Registrar> {

    public init(permissions: CKApplicationPermissions = [], containerId: String? = .None) {
        super.init(permissions, registrar: Registrar.containerWithIdentifier(containerId))
    }
}

public final class CloudContainer: NSObject, CloudContainerRegistrarType {

    public static func containerWithIdentifier(identifier: String?) -> CloudContainer {
        let container = CloudContainer()
        if let id = identifier {
            container.cloudKitContainer = CKContainer(identifier: id)
        }
        return container
    }

    public private(set) var cloudKitContainer: CKContainer = CKContainer.defaultContainer()

    public func opr_accountStatusWithCompletionHandler(completionHandler: (CKAccountStatus, NSError?) -> Void) {
        cloudKitContainer.accountStatusWithCompletionHandler(completionHandler)
    }

    public func opr_statusForApplicationPermission(applicationPermission: CKApplicationPermissions, completionHandler: CKApplicationPermissionBlock) {
        cloudKitContainer.statusForApplicationPermission(applicationPermission, completionHandler: completionHandler)
    }

    public func opr_requestApplicationPermission(applicationPermission: CKApplicationPermissions, completionHandler: CKApplicationPermissionBlock) {
        cloudKitContainer.requestApplicationPermission(applicationPermission, completionHandler: completionHandler)
    }
}

extension Capability {
    public typealias Cloud = CloudCapability<CloudContainer>
}

extension CloudCapability where Registrar: CloudContainer {

    public var container: CKContainer {
        return registrar.cloudKitContainer
    }

    }
}

/**
 A refined CapabilityRegistrarType for Capability.Cloud. This
 protocol defines two functions which the registrar uses to get
 the current authorization status and request access.
*/
public protocol CloudContainerRegistrarType: CapabilityRegistrarType {

    /**
     Provide an instance of Self with the given identifier. This is
     because we need to determined the capability of a specific cloud 
     kit container.
    */
    static func containerWithIdentifier(identifier: String?) -> Self

    /**
     Get the account status, a CKAccountStatus.

     - parameter completionHandler: a completion handler which receives the account status.
     */
    func opr_accountStatusWithCompletionHandler(completionHandler: (CKAccountStatus, NSError?) -> Void)

    /**
     Get the application permission, a CKApplicationPermissions.

     - parameter applicationPermission: the CKApplicationPermissions
     - parameter completionHandler: a CKApplicationPermissionBlock closure
     */
    func opr_statusForApplicationPermission(applicationPermission: CKApplicationPermissions, completionHandler: CKApplicationPermissionBlock)

    /**
     Request the application permission, a CKApplicationPermissions.

     - parameter applicationPermission: the CKApplicationPermissions
     - parameter completionHandler: a CKApplicationPermissionBlock closure
     */
    func opr_requestApplicationPermission(applicationPermission: CKApplicationPermissions, completionHandler: CKApplicationPermissionBlock)
}

/**
The Cloud capability, which generic over CloudContainerRegistrarType.
 
 Framework consumers should not use this directly, but instead
 use Capability.Cloud. So that its usage is like this:

 ```swift

 GetAuthorizationStatus(Capability.Cloud()) { status in
    // check the status etc.
 }
 ```

 - see: Capability.Cloud
*/
public class _CloudCapability<Registrar: CloudContainerRegistrarType>: NSObject, CapabilityType {

    /// - returns: a String, the name of the capability
    public let name: String

    /// - returns: a CKApplicationPermissions, the required permissions for the container
    public let requirement: CKApplicationPermissions

    var hasRequirements: Bool {
