Module: Themeable::Theme
- Defined in:
- lib/themeable/theme.rb
Overview
Theme’s basic module, automatically define methods
- theme_name
- root_path
- theme_path
Class Method Summary collapse
Class Method Details
.included(subclass) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/themeable/theme.rb', line 8 def self.included(subclass) Themeable.add_theme(subclass) # set default values caller_file = caller.first if caller_file =~ %r{/lib/theme_([^/]*)\.rb} default_theme_name = $1.to_sym default_root = File.(File.join(caller_file, '../../')) end subclass.instance_eval <<-RUBY, __FILE__, __LINE__ + 1 @theme_name = #{default_theme_name.inspect} # Theme name # # @return [Symbol] def theme_name @theme_name || raise("Theme name can't be resolved from path: #{__FILE__}") end @root_path = #{default_root.inspect} # Theme project's root path # # @return [String] def root_path @root_path || raise("Theme project's root path is no defined") end # Theme's relative path, 'theme' by default # # @return [String] default is 'theme' def theme_path @theme_path || 'theme' end RUBY end |