class ReservedSubdomain::Literal
Attributes
subdomain[R]
Public Class Methods
literals()
click to toggle source
If the env var is set then we pre-load all the reserved literals into a big array. This makes checking for reserved subdomains quicker but at the expense of keeping the big array in memory.
If you're only checking for reserved subdomains when a user creates a new account then it may be better to load the literals from the file each time.
# File lib/reserved_subdomain/literal.rb, line 11 def literals @literals ||= ENV['RESERVED_SUBDOMAIN_PRELOAD'] ? load_literals : nil end
load_literals()
click to toggle source
# File lib/reserved_subdomain/literal.rb, line 15 def load_literals ReservedSubdomain::File.load('*') end
new(subdomain)
click to toggle source
# File lib/reserved_subdomain/literal.rb, line 22 def initialize(subdomain) @subdomain = subdomain end
Public Instance Methods
reserved?()
click to toggle source
# File lib/reserved_subdomain/literal.rb, line 26 def reserved? literals.include? subdomain end
Private Instance Methods
literals()
click to toggle source
# File lib/reserved_subdomain/literal.rb, line 32 def literals self.class.literals || self.class.load_literals end