         self.error = error
     }
 
+    /**
+     Determine whether the application permissions have been met.
+     This method takes into account, any errors received from CloudKit,
+     the account status, application permission status, and the required
+     application permissions.
+    */
     public func isRequirementMet(requirement: CKApplicationPermissions) -> Bool {
         if let _ = error {
             return false

    }
}

public protocol CloudContainerRegistrarType: CapabilityRegistrarType {

    static func containerWithIdentifier(identifier: String?) -> Self

    func opr_accountStatusWithCompletionHandler(completionHandler: (CKAccountStatus, NSError?) -> Void)
    func opr_statusForApplicationPermission(applicationPermission: CKApplicationPermissions, completionHandler: CKApplicationPermissionBlock)
    func opr_requestApplicationPermission(applicationPermission: CKApplicationPermissions, completionHandler: CKApplicationPermissionBlock)
}

public class _CloudCapability<Registrar: CloudContainerRegistrarType>: NSObject, CapabilityType {

    public let name: String
    public let requirement: CKApplicationPermissions

    var hasRequirements: Bool {


}

/**
 CloudCapability provides an initializer which allows the consumer to provide a
 cloud kit container identifier.
*/
public class CloudCapability<Registrar: CloudContainerRegistrarType>: _CloudCapability<Registrar> {

    /**
     Initialize the CloudCapability with permissions and optionally a specific
     CKContainer identifier.

     - parameter permissions: the CKApplicationPermissions, defaults to empty set.
     - parameter containerId: an String?, defaults to .None which corresponds to the default CKContainer.
    */
    public init(permissions: CKApplicationPermissions = [], containerId: String? = .None) {
        super.init(permissions, registrar: Registrar.containerWithIdentifier(containerId))
    }
}

/**
 A registrar for CKContainer.
*/
public final class CloudContainerRegistrar: NSObject, CloudContainerRegistrarType {

    /// Provide a CloudContainerRegistrar for a CKContainer with the given identifier.
    public static func containerWithIdentifier(identifier: String?) -> CloudContainerRegistrar {
        let container = CloudContainerRegistrar()
        if let id = identifier {
            container.cloudKitContainer = CKContainer(identifier: id)
        }
        return container
    }

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

    /**
     Get the account status, a CKAccountStatus.

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

    /**
     Get the application permission, a CKApplicationPermissions.

     - parameter applicationPermission: the CKApplicationPermissions
     - parameter completionHandler: a CKApplicationPermissionBlock closure
     */
    public func opr_statusForApplicationPermission(applicationPermission: CKApplicationPermissions, completionHandler: CKApplicationPermissionBlock) {
        cloudKitContainer.statusForApplicationPermission(applicationPermission, completionHandler: completionHandler)
    }

    /**
     Request the application permission, a CKApplicationPermissions.

     - parameter applicationPermission: the CKApplicationPermissions
     - parameter completionHandler: a CKApplicationPermissionBlock closure
     */
    public func opr_requestApplicationPermission(applicationPermission: CKApplicationPermissions, completionHandler: CKApplicationPermissionBlock) {
        cloudKitContainer.requestApplicationPermission(applicationPermission, completionHandler: completionHandler)
    }
}

extension Capability {

    /**
     # Capability.Cloud
     
     This type represents the app's permission to access a particular CKContainer.
     
     For framework consumers - use with GetAuthorizationStatus, Authorize and
     AuthorizedFor. 
     
     For example, authorize usage of the default container
     
     ```swift
     Authorize(Capability.Cloud()) { available, status in
        // etc
     }
     ```

     For example, authorize usage of another container;
     
     ```swift
     Authorize(Capability.Cloud(containerId: "iCloud.com.myapp.my-container-id)) { available, status in
        // etc
     }
     ```
    */
    public typealias Cloud = CloudCapability<CloudContainerRegistrar>
}

extension CloudCapability where Registrar: CloudContainerRegistrar {

    /// - returns: the `CKContainer`
    public var container: CKContainer {
        return registrar.cloudKitContainer
    }
