lib/rib/plugin.rb in rib-1.5.1 vs lib/rib/plugin.rb in rib-1.5.2

- old
+ new

@@ -1,8 +1,7 @@ -module Rib; end -module Rib::Plugin +module Rib; module Plugin attr_accessor :disabled def enable self.disabled = false if block_given? then yield else enabled? end @@ -23,12 +22,24 @@ def disabled? !!disabled end + # Backward compatibility + def const_missing mod + if Rib.const_defined?(mod) + Rib.warn("Using #{mod} is deprecated, please change to Rib::#{mod}", + "This compatibility layer would be removed in Rib 1.6+", + "Called: #{caller.first}") + Rib.const_get(mod) + else + super + end + end + def self.extended mod - mod.send(:include, Rib) + return unless mod.name snake_name = mod.name.sub(/(\w+::)+?(\w+)$/, '\2'). gsub(/([A-Z][a-z]*)/, '\\1_').downcase[0..-2] code = (%w[enable disable].map{ |meth| @@ -45,6 +56,6 @@ RUBY }).join("\n") Rib.singleton_class.module_eval(code, __FILE__, __LINE__) end -end +end; end