 //  Copyright © 2016 Sandcastle Application Development. All rights reserved.
 //
 
+import Foundation
 import AWSDynamoDB
 
 final class Advertisement: CustomDebugStringConvertible
 {
-    static var ads = [Advertisement]()
+	static var ads = [String:[Advertisement]]()
+
+	static func apropos(identifier: String, ofFeed feed: FeedCategory, inAdministration administration: String) -> [Advertisement]? {
+		return ads[administration]?.filter { $0.apropos(identifier, ofFeed: feed) }
+	}
     
 	enum Style: Int {
 		case Page, Overlay

        get {
            let db = AdvertisementDB()
            db.administration = administration
            db.feeds = feeds.map { $0.0.rawValue + ":" + $0.1 }
            db.pages = pages.map { NSNumber(integer: $0) }
            db.style = NSNumber(integer: style.rawValue)
            db.media = media

        case All = "a", Pregame = "p", Venue = "v"
    }
    
    typealias FeedMask = [FeedCategory:NSRegularExpression]

	let administration: String
    let feeds: FeedMask
