Class: Locomotive::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/locomotive/configuration.rb

Constant Summary collapse

@@defaults =
{
  name:                   'LocomotiveApp',
  domain:                 'example.com',
  reserved_subdomains:    %w{www admin email blog webmail mail support help site sites},
  # forbidden_paths:      %w{layouts snippets stylesheets javascripts assets admin system api},
  reserved_slugs:         %w{stylesheets javascripts assets admin locomotive images api pages edit},
  locales:                %w{en de fr pl pt-BR it nl nb es ru et ja zh-CN cs bg},
  site_locales:           %w{en de fr pl pt-BR it nl nb es ru et ja zh-CN cs bg},
  cookie_key:             '_locomotive_session',
  enable_logs:            false,
  enable_admin_ssl:       false,
  delayed_job:            false,
  default_locale:         :en,
  mailer_sender:          '[email protected]',
  manage_subdomain:       false,
  manage_manage_domains:  false,
  ui:                     {
    latest_entries_nb:    5,
    max_content_types:    2,
    per_page:             10
  },
  rack_cache:             {
    verbose:     true,
    metastore:   URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
    entitystore: URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
  },
  devise_modules:             [:rememberable, :database_authenticatable, :token_authenticatable, :recoverable, :trackable, :validatable, :encryptable, { encryptor: :sha1 }],
  context_assign_extensions:  { },
  models_for_templatization:  [],
  csrf_protection:            false
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



38
39
40
# File 'lib/locomotive/configuration.rb', line 38

def initialize
  @@settings = self.class.get_from_hash(@@defaults)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



78
79
80
# File 'lib/locomotive/configuration.rb', line 78

def method_missing(name, *args, &block)
  self.settings.send(name, *args, &block)
end

Class Method Details

.settingsObject



42
43
44
# File 'lib/locomotive/configuration.rb', line 42

def self.settings
  @@settings
end

Instance Method Details

#manage_domains?Boolean

Returns:



54
55
56
# File 'lib/locomotive/configuration.rb', line 54

def manage_domains?
  self.manage_domains == true
end

#manage_subdomain?Boolean

Returns:



50
51
52
# File 'lib/locomotive/configuration.rb', line 50

def manage_subdomain?
  self.manage_subdomain == true
end

#manage_subdomain_n_domains?Boolean

Returns:



58
59
60
# File 'lib/locomotive/configuration.rb', line 58

def manage_subdomain_n_domains?
  self.manage_subdomain? && self.manage_domains?
end

#multi_sites?Boolean

Returns:



46
47
48
# File 'lib/locomotive/configuration.rb', line 46

def multi_sites?
  self.multi_sites != false
end

#multi_sites_or_manage_domains?Boolean

Returns:



62
63
64
# File 'lib/locomotive/configuration.rb', line 62

def multi_sites_or_manage_domains?
  self.multi_sites? || self.manage_domains?
end

#reserved_subdomainsObject



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/locomotive/configuration.rb', line 66

def reserved_subdomains
  if self.multi_sites?
    if self.multi_sites.reserved_subdomains.blank?
      @@defaults[:reserved_subdomains]
    else
      self.multi_sites.reserved_subdomains
    end
  else
    []
  end
end