Class: Platform::SiteConfiguration

Inherits:
Object
  • Object
show all
Defined in:
app/models/platform/site_configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_reader, site) ⇒ SiteConfiguration

Returns a new instance of SiteConfiguration.



3
4
5
6
7
# File 'app/models/platform/site_configuration.rb', line 3

def initialize(config_reader, site)
  @config_reader = config_reader
  @site          = site
  @assets        = {}
end

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



43
44
45
# File 'app/models/platform/site_configuration.rb', line 43

def site
  @site
end

Instance Method Details

#asset_folder(type) ⇒ Object



34
35
36
37
38
39
40
41
# File 'app/models/platform/site_configuration.rb', line 34

def asset_folder(type)
  case type
    when :base then
      @assets[:base] ||= File.expand_path(File.join([Rails.root, config_reader.sites_location, site, "public"]))
    else
      @assets[type.to_sym] ||= File.expand_path(File.join([Rails.root, config_reader.sites_location, site, "public", type.to_s]))
  end
end

#component_enabled?(component_name) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/platform/site_configuration.rb', line 30

def component_enabled? component_name
  !read_array("disabled_components", []).include?(component_name)
end

#get(path) ⇒ Object



9
10
11
# File 'app/models/platform/site_configuration.rb', line 9

def get(path)
  config_reader.get site, path
end

#layout(name, page_type = "templated_page") ⇒ Object



25
26
27
28
# File 'app/models/platform/site_configuration.rb', line 25

def layout(name, page_type = "templated_page")
  layout_name = get "templates.standard.#{page_type}.#{name}.layout"
  "/#{config_reader.sites_location}#{site}/app/views/layouts/#{layout_name}"
end

#read_array(path, default = nil) ⇒ Object



13
14
15
# File 'app/models/platform/site_configuration.rb', line 13

def read_array(path, default = nil)
  read_type path, Array, default
end

#read_hash(path, default = nil) ⇒ Object



21
22
23
# File 'app/models/platform/site_configuration.rb', line 21

def read_hash(path, default = nil)
  read_type path, Hash, default
end

#read_string(path, default = nil) ⇒ Object



17
18
19
# File 'app/models/platform/site_configuration.rb', line 17

def read_string(path, default = nil)
  read_type path, String, default
end