Module: Yap::World::AddonMethods::ClassMethods
- Included in:
- Yap::World::Addon
- Defined in:
- lib/yap/world/addons.rb
Instance Method Summary collapse
Instance Method Details
#addon_name ⇒ Object
15 16 17 |
# File 'lib/yap/world/addons.rb', line 15 def addon_name @addon_name ||= self.name.split(/::/).last.scan(/[A-Z][^A-Z]+/).map(&:downcase).reject{ |f| f == "addon" }.join("_").to_sym end |
#load_addon ⇒ Object
10 11 12 13 |
# File 'lib/yap/world/addons.rb', line 10 def load_addon # no-op, override in subclass if you need to do anything special # when your addon is first loaded when the shell starts end |
#require(name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/yap/world/addons.rb', line 19 def require(name) directory = File.dirname caller[0].split(':').first lib_path = File.join directory, "lib" support_file = File.join lib_path, "#{name}.rb" namespace = self.name.split('::').reduce(Object) do |context,n| o = context.const_get(n) break o if o.is_a?(Namespace) o end if File.exists?(support_file) && namespace namespace.module_eval IO.read(support_file), support_file, lineno=1 else super(name) end end |