class Archangel::Theme::ThemableController
Apply Archangel
theme to page
Attributes
theme_name[R]
Theme
name
Public Class Methods
apply_theme(controller_class, theme, options = {})
click to toggle source
Apply theme
@param controller_class [Class] the controller @param theme [String] the theme @param options [Hash] the theme options
# File lib/archangel/theme/themable_controller.rb, line 25 def apply_theme(controller_class, theme, options = {}) filter_method = before_filter_method(options) options = options.slice(:only, :except) controller_class.class_eval do define_method :layout_from_theme do theme_instance.theme_name end alias_method :current_theme, :layout_from_theme define_method :theme_instance do @theme_instance ||= Archangel::Theme::ThemableController.new(self, theme) end private :layout_from_theme, :theme_instance layout :layout_from_theme, options helper_method :current_theme end controller_class.send(filter_method, options) do |controller| controller.prepend_view_path theme_instance.theme_view_path end end
new(controller, theme)
click to toggle source
Theme
initializer
@param controller [Object] the controller @param theme [String] the theme
# File lib/archangel/theme/themable_controller.rb, line 66 def initialize(controller, theme) @controller = controller @theme_name = theme_name_identifier(theme) end
Private Class Methods
before_filter_method(options)
click to toggle source
# File lib/archangel/theme/themable_controller.rb, line 55 def before_filter_method(options) options.delete(:prepend) ? :prepend_before_action : :before_action end
Public Instance Methods
theme_view_path()
click to toggle source
Archangel
theme path
@return [String] the path to the theme
# File lib/archangel/theme/themable_controller.rb, line 76 def theme_view_path path = Rails.root path = Archangel::Engine.root if @theme_name == Archangel::THEME_DEFAULT "#{path}/app/themes/#{@theme_name}/views" end
Private Instance Methods
theme_name_identifier(theme)
click to toggle source
# File lib/archangel/theme/themable_controller.rb, line 85 def theme_name_identifier(theme) @controller.send(theme).to_s end