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},
  :site_locales           => %w{en de fr pl pt-BR it nl nb es ru et},
  :cookie_key             => '_locomotive_session',
  :enable_logs            => 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
  },
  :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.



36
37
38
# File 'lib/locomotive/configuration.rb', line 36

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



72
73
74
# File 'lib/locomotive/configuration.rb', line 72

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

Class Method Details

.settingsObject



40
41
42
# File 'lib/locomotive/configuration.rb', line 40

def self.settings
  @@settings
end

Instance Method Details

#manage_domains?Boolean

Returns:



52
53
54
# File 'lib/locomotive/configuration.rb', line 52

def manage_domains?
  self.manage_domains == true
end

#manage_subdomain?Boolean

Returns:



48
49
50
# File 'lib/locomotive/configuration.rb', line 48

def manage_subdomain?
  self.manage_subdomain == true
end

#manage_subdomain_n_domains?Boolean

Returns:



56
57
58
# File 'lib/locomotive/configuration.rb', line 56

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

#multi_sites?Boolean

Returns:



44
45
46
# File 'lib/locomotive/configuration.rb', line 44

def multi_sites?
  self.multi_sites != false
end

#reserved_subdomainsObject



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/locomotive/configuration.rb', line 60

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