class Percolate::Facet::HostnameFacet
A facet for looking up entities based on hostname.
Attributes
domains[RW]
hostnames[RW]
organizations[RW]
Public Class Methods
new()
click to toggle source
# File lib/percolate/facet/hostname_facet.rb, line 24 def initialize @hostnames = {} @domains = {} @organizations = {} end
Public Instance Methods
find(hostname)
click to toggle source
# File lib/percolate/facet/hostname_facet.rb, line 30 def find(hostname) return @hostnames[hostname] if @hostnames.include?(hostname) comps = hostname.split(".", -1) domain = comps[1...3].join(".") return @domains[domain] if @domains.include?(domain) organization = comps[1] @organizations.fetch(organization, organization) end
merge(other)
click to toggle source
# File lib/percolate/facet/hostname_facet.rb, line 43 def merge(other) raise ArgumentError, "Please provide another #{self.class}" if !other.is_a?(HostnameFacet) merged = HostnameFacet.new merged.hostnames = @hostnames.merge(other.hostnames) merged.domains = @domains.merge(other.domains) merged.organizations = @organizations.merge(other.organizations) merged end