lib/plugins/plugin_base.rb in rsence-pre-2.1.0.9 vs lib/plugins/plugin_base.rb in rsence-pre-2.1.0.10

- old
+ new

@@ -34,10 +34,15 @@ # * {Plugin__ Plugin} -- The Plugin base class # * {Servlet__ Servlet} -- The Servlet base class # * {GUIPlugin__ GUIPlugin} -- The GUIPlugin base class module PluginBase + # When a method is missing, tries a call via pluginmanager. (Eliminates plugins.plugin_name.method_name calls -> plugin_name.method_name) + def method_missing( sym, *args, &block ) + @plugins.method_missing( sym, *args, &block ) + end + # @private External accessor for @plugins # @return [PluginManager] The PluginManager the instance belongs to. attr_reader :plugins # Extend this method do any initial configuration instead of extending the +initialize+ constructor, which should *never* be done in plugins. @@ -121,9 +126,18 @@ warn "file_write error for path #{path} #{e}" return false end end alias file_save file_write + + # Yaml writer utility. + # + # Wrapper for #file_write + # Converts +data+ to yaml and then calls file_write with the result. + def yaml_write( path, data ) + file_write( path, data.to_yaml ) + end + # Path utility # # Makes a full, absolute path using the plugin bundle as the default path when a relative path is given. Returns just the bundle's local path, if no parameters given. #