Class: ShinyThemes::Theme
- Inherits:
-
Object
- Object
- ShinyThemes::Theme
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/shiny_themes/theme.rb
Overview
Theme model class which is meant to be associated with one or more controllers. This theme "contains" assets (css, js, etc) as well as any views the them overrides and/or defines.
Instance Attribute Summary collapse
-
#layout ⇒ String
] the name of the default layout to use.
-
#name ⇒ String
readonly
The name of the theme which must match the root directory name where theme files are located.
Instance Method Summary collapse
-
#asset_path ⇒ Pathname
Path to the theme's assets directory.
-
#initialize(options = {}) ⇒ Theme
constructor
A new instance of Theme.
-
#path ⇒ Pathname
Path to the theme's root directory.
-
#views_path ⇒ Pathname
Path to the theme's view directory.
Constructor Details
#initialize(options = {}) ⇒ Theme
Returns a new instance of Theme.
41 42 43 44 45 |
# File 'lib/shiny_themes/theme.rb', line 41 def initialize( = {}) @name = [:name] || Rails.application.config.theme.name @layout = [:layout] || Rails.application.config.theme.layout || 'application' @theme_path = [:theme_path] || Rails.application.config.theme.path end |
Instance Attribute Details
#layout ⇒ String
Returns ] the name of the default layout to use. Defaults to config.theme.layout or 'application' if this does not exist.
12 13 14 |
# File 'lib/shiny_themes/theme.rb', line 12 def layout @layout end |
#name ⇒ String (readonly)
Returns the name of the theme which must match the root directory name where theme files are located. Defaults to config.theme.name value.
9 10 11 |
# File 'lib/shiny_themes/theme.rb', line 9 def name @name end |
Instance Method Details
#asset_path ⇒ Pathname
Returns Path to the theme's assets directory.
58 59 60 |
# File 'lib/shiny_themes/theme.rb', line 58 def asset_path path.join('assets') end |
#path ⇒ Pathname
Returns Path to the theme's root directory.
48 49 50 |
# File 'lib/shiny_themes/theme.rb', line 48 def path Rails.root.join(@theme_path, @name) end |
#views_path ⇒ Pathname
Returns Path to the theme's view directory.
53 54 55 |
# File 'lib/shiny_themes/theme.rb', line 53 def views_path path.join('views') end |