Class: SiteFramework::Domain

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
app/models/site_framework/domain.rb

Overview

This model represent a Domain. Each domain belongs to a [Site] model and may or may not belongs to another Domain

Constant Summary collapse

PATTERN =
/\A[a-z0-9]*(\.?[a-z0-9]+)\.[a-z]{2,5}(:[0-9]{1,5})?(\/.)?$/ix

Instance Method Summary collapse

Instance Method Details

#normalize_nameObject



41
42
43
# File 'app/models/site_framework/domain.rb', line 41

def normalize_name
  self.name = name.downcase
end

#parentObject



21
22
23
# File 'app/models/site_framework/domain.rb', line 21

def parent
  # TODO: return a domain with alias == false
end

#valid_domain_name?Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
# File 'app/models/site_framework/domain.rb', line 45

def valid_domain_name?
  if read_attribute :alias
    false unless name =~ PATTERN
    # TODO: Check the owner of domain
  else
    true
  end
end