Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor reorganizations in YapDatabaseExtensions.swift #78

Merged
merged 3 commits into from Jan 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 24 additions & 20 deletions YapDatabaseExtensions/Shared/YapDatabaseExtensions.swift
Expand Up @@ -252,6 +252,18 @@ extension Persistable {
}
}

// MARK: Functions

public func keyForPersistable<P: Persistable>(persistable: P) -> String {
return persistable.key
}

public func indexForPersistable<P: Persistable>(persistable: P) -> YapDB.Index {
return persistable.index
}

// MARK: -

/// A facade interface for a read transaction.
public protocol ReadTransactionType {

Expand Down Expand Up @@ -547,14 +559,11 @@ extension YapDatabase: DatabaseType {
}
}

// MARK: - YapDB.Index

// MARK: Hashable etc

extension YapDB.Index: CustomStringConvertible, Hashable {
// MARK: Hashable & Equality

public var description: String {
return "\(collection):\(key)"
}
extension YapDB.Index: Hashable {

public var hashValue: Int {
return description.hashValue
Expand All @@ -565,6 +574,15 @@ public func == (a: YapDB.Index, b: YapDB.Index) -> Bool {
return (a.collection == b.collection) && (a.key == b.key)
}

// MARK: CustomStringConvertible

extension YapDB.Index: CustomStringConvertible {

public var description: String {
return "\(collection):\(key)"
}
}

// MARK: ValueCoding

extension YapDB.Index: ValueCoding {
Expand Down Expand Up @@ -592,20 +610,6 @@ public final class YapDBIndexCoder: NSObject, NSCoding, CodingType {
}
}





// MARK: - Functions

public func keyForPersistable<P: Persistable>(persistable: P) -> String {
return persistable.key
}

public func indexForPersistable<P: Persistable>(persistable: P) -> YapDB.Index {
return persistable.index
}

// MARK: - Deprecations

@available(*, unavailable, renamed="Persistable")
Expand Down