app/models/locomotive/extensions/site/subdomain_domains.rb in locomotive_cms-2.0.3 vs app/models/locomotive/extensions/site/subdomain_domains.rb in locomotive_cms-2.1.0

- old
+ new

@@ -8,30 +8,30 @@ if Locomotive.config.multi_sites_or_manage_domains? ## fields ## field :subdomain - field :domains, :type => Array, :default => [] + field :domains, type: Array, default: [] ## indexes - index :domains + index domains: 1 ## validations ## validates_presence_of :subdomain validates_uniqueness_of :subdomain - validates_exclusion_of :subdomain, :in => Locomotive.config.reserved_subdomains - validates_format_of :subdomain, :with => Locomotive::Regexps::SUBDOMAIN, :allow_blank => true + validates_exclusion_of :subdomain, in: Locomotive.config.reserved_subdomains + validates_format_of :subdomain, with: Locomotive::Regexps::SUBDOMAIN, allow_blank: true validate :domains_must_be_valid_and_unique ## callbacks ## before_save :add_subdomain_to_domains after_destroy :clear_cache_for_all_domains ## named scopes ## - scope :match_domain, lambda { |domain| { :any_in => { :domains => [*domain] } } } + scope :match_domain, lambda { |domain| { any_in: { domains: [*domain] } } } scope :match_domain_with_exclusion_of, lambda { |domain, site| - { :any_in => { :domains => [*domain] }, :where => { :_id.ne => site.id } } + { any_in: { domains: [*domain] }, where: { :_id.ne => site.id } } } send :include, InstanceMethods end end @@ -73,14 +73,14 @@ def domains_must_be_valid_and_unique return if self.domains.empty? self.domains_without_subdomain.each do |domain| if self.class.match_domain_with_exclusion_of(domain, self).any? - self.errors.add(:domains, :domain_taken, :value => domain) + self.errors.add(:domains, :domain_taken, value: domain) end if not domain =~ Locomotive::Regexps::DOMAIN - self.errors.add(:domains, :invalid_domain, :value => domain) + self.errors.add(:domains, :invalid_domain, value: domain) end end end def clear_cache_for_all_domains