Skip to content

Commit

Permalink
development: updated subject and object search for Relationship and A…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
Daniel Dahan committed Nov 13, 2016
1 parent 5bc0d48 commit 172290e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Sources/Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,9 @@ extension Array where Element: Action {
public func subject(types: [String]) -> [Entity] {
var s = Set<Entity>()
forEach { [types = types] (a) in
s.insert(a.suject(types: types))
a.subject(types: types).forEach {
s.insert($0)
}
}
return [Entity](s)
}
Expand All @@ -605,7 +607,9 @@ extension Array where Element: Action {
public func object(types: [String]) -> [Entity] {
var s = Set<Entity>()
forEach { [types = types] (a) in
s.insert(a.object(types: types))
a.object(types: types).forEach {
s.insert($0)
}
}
return [Entity](s)
}
Expand Down
20 changes: 18 additions & 2 deletions Sources/Relationship.swift
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,15 @@ extension Array where Element: Relationship {
public func subject(types: [String]) -> [Entity] {
var s = Set<Entity>()
forEach { [types = types] (r) in
s.insert(r.subject(types: types))
guard let e = r.subject else {
return
}

guard types.contains(e.type) else {
return
}

s.insert(e)
}
return [Entity](s)
}
Expand All @@ -472,7 +480,15 @@ extension Array where Element: Relationship {
public func object(types: [String]) -> [Entity] {
var s = Set<Entity>()
forEach { [types = types] (r) in
s.insert(r.object(types: types))
guard let e = r.subject else {
return
}

guard types.contains(e.type) else {
return
}

s.insert(e)
}
return [Entity](s)
}
Expand Down

0 comments on commit 172290e

Please sign in to comment.