Class: Platform::SiteConfiguration
- Inherits:
-
Object
- Object
- Platform::SiteConfiguration
- Defined in:
- app/models/platform/site_configuration.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
- #asset_folder(type) ⇒ Object
- #component_enabled?(component_name) ⇒ Boolean
- #get(path) ⇒ Object
-
#initialize(config_reader, site) ⇒ SiteConfiguration
constructor
A new instance of SiteConfiguration.
- #layout(name, page_type = "templated_page") ⇒ Object
- #read_array(path, default = nil) ⇒ Object
- #read_hash(path, default = nil) ⇒ Object
- #read_string(path, default = nil) ⇒ Object
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
#site ⇒ Object (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.(File.join([Rails.root, config_reader.sites_location, site, "public"])) else @assets[type.to_sym] ||= File.(File.join([Rails.root, config_reader.sites_location, site, "public", type.to_s])) end end |
#component_enabled?(component_name) ⇒ 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 |