Class: Livetext::Handler::Mixin
- Includes:
- GlobalHelpers, Livetext::Helpers
- Defined in:
- lib/livetext/handler/mixin.rb
Overview
Handle a .mixin
Constant Summary
Constants included from Livetext::Helpers
Livetext::Helpers::Comment, Livetext::Helpers::DollarDot, Livetext::Helpers::DotCmd, Livetext::Helpers::ESCAPING, Livetext::Helpers::Sigil, Livetext::Helpers::Space, Livetext::Helpers::TTY
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, parent) ⇒ Mixin
constructor
Livetext::Handler::Mixin.
- #read_mixin ⇒ Object
Methods included from GlobalHelpers
#check_disallowed, #check_file_exists, #cwd_root?, #grab_file, #search_upward
Methods included from Livetext::Helpers
#check_disallowed, #check_file_exists, #debug, #escape_html, #find_file, #friendly_error, #get_name_data, #grab_file, #graceful_error, #handle_dollar_dot, #handle_dotcmd, #handle_scomment, #include_file, #invoke_dotcmd, #onoff, #process_file, #process_line, #read_variables, rx, #search_upward, #set_variables, #setfile, #setfile!, #setvar, #showme
Constructor Details
#initialize(name, parent) ⇒ Mixin
Livetext::Handler::Mixin
12 13 14 15 16 |
# File 'lib/livetext/handler/mixin.rb', line 12 def initialize(name, parent) # Livetext::Handler::Mixin @name = name @file = find_file(name, ".rb", "plugin") parent.graceful_error FileNotFound(name) if @file.nil? end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
10 11 12 |
# File 'lib/livetext/handler/mixin.rb', line 10 def file @file end |
Class Method Details
.get_module(filename, parent) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/livetext/handler/mixin.rb', line 18 def self.get_module(filename, parent) handler = self.new(filename, parent) modname, code = handler.read_mixin eval(code) # Avoid in the future newmod = Object.const_get("::" + modname) newmod # return actual module end |
Instance Method Details
#read_mixin ⇒ Object
26 27 28 29 30 |
# File 'lib/livetext/handler/mixin.rb', line 26 def read_mixin modname = @name.gsub("/","_").capitalize meths = grab_file(@file) # already has .rb? [modname, "module ::#{modname}; #{meths}\nend"] end |