Skip to content

Commit

Permalink
Doc comments for property extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
neilpa committed Dec 16, 2015
1 parent 590b569 commit d8c9ca2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Source/Property.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@
import ReactiveCocoa

extension PropertyType where Value == Bool {
/// The conjunction of `self` and `other`.
public func and<P: PropertyType where P.Value == Bool>(other: P) -> AndProperty {
return AndProperty(terms: [AnyProperty(self), AnyProperty(other)])
}

/// The conjunction of `self` and `other`.
public func and(other: AnyProperty<Bool>) -> AndProperty {
return AndProperty(terms: [AnyProperty(self), other])
}

/// The disjunction of `self` and `other`.
public func or<P: PropertyType where P.Value == Bool>(other: P) -> OrProperty {
return OrProperty(terms: [AnyProperty(self), AnyProperty(other)])
}

/// The disjunction of `self` and `other`.
public func or(other: AnyProperty<Bool>) -> OrProperty {
return OrProperty(terms: [AnyProperty(self), other])
}

/// A negated property of `self`.
public func not() -> NotProperty {
return NotProperty(source: AnyProperty(self), invert: true)
}
}

/// Specialized `PropertyType` for the conjuction of a set of boolean properties.
public struct AndProperty: PropertyType {
public let terms: [AnyProperty<Bool>]

Expand All @@ -44,10 +50,12 @@ public struct AndProperty: PropertyType {
}
}

/// Creates a new property with an additional conjunctive term.
public func and<P : PropertyType where P.Value == Bool>(other: P) -> AndProperty {
return AndProperty(terms: terms + [AnyProperty(other)])
}

/// Creates a new property with an additional conjunctive term.
public func and(other: AnyProperty<Bool>) -> AndProperty {
return AndProperty(terms: terms + [other])
}
Expand All @@ -57,6 +65,7 @@ public struct AndProperty: PropertyType {
}
}

/// Specialized `PropertyType` for the disjunction of a set of boolean properties.
public struct OrProperty: PropertyType {
public let terms: [AnyProperty<Bool>]

Expand All @@ -71,10 +80,12 @@ public struct OrProperty: PropertyType {
}
}

/// Creates a new property with an additional disjunctive term.
public func or<P : PropertyType where P.Value == Bool>(other: P) -> OrProperty {
return OrProperty(terms: terms + [AnyProperty(other)])
}

/// Creates a new property with an additional disjunctive term.
public func or(other: AnyProperty<Bool>) -> OrProperty {
return OrProperty(terms: terms + [other])
}
Expand All @@ -84,6 +95,7 @@ public struct OrProperty: PropertyType {
}
}

/// Specialized `PropertyType` for the negation of a boolean property.
public struct NotProperty: PropertyType {
private let source: AnyProperty<Bool>
private let invert: Bool
Expand All @@ -96,6 +108,7 @@ public struct NotProperty: PropertyType {
return source.producer.map { $0 != self.invert }
}

/// A negated property of `self`.
public func not() -> NotProperty {
return NotProperty(source: source, invert: !invert)
}
Expand Down

0 comments on commit d8c9ca2

Please sign in to comment.