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 " @theme_name = \#{default_theme_name.inspect}\n\n # Theme name\n #\n # @return [Symbol]\n def theme_name\n @theme_name || raise(\"Theme name can't be resolved from path: \#{__FILE__}\")\n end\n\n @root_path = \#{default_root.inspect}\n\n # Theme project's root path\n #\n # @return [String]\n def root_path\n @root_path || raise(\"Theme project's root path is no defined\")\n end\n\n # Theme's relative path, 'theme' by default\n #\n # @return [String] default is 'theme'\n def theme_path\n @theme_path || 'theme'\n end\n\n RUBY\nend\n", __FILE__, __LINE__ + 1 |