module Naplug::ClassMethods
Attributes
_time[R]
@!attribute [r] plugins
@return [Hash<Symbol, Plugin>] metaplugins
plugins[R]
@!attribute [r] plugins
@return [Hash<Symbol, Plugin>] metaplugins
Public Instance Methods
meta(m)
click to toggle source
# File lib/naplug.rb, line 44 def meta(m) @_time = { :start => Time.now } # if m[:benchmark] end
plugin(*tagmeta, &block)
click to toggle source
Create a metaplugin (which basically contains a tag and a block) @param tag [Symbol] the plugin tag @return [Plugin] a metaplugin
# File lib/naplug.rb, line 35 def plugin(*tagmeta, &block) tag, meta = tagmeta_grok tagmeta @metas = Hash.new unless @metas @metas[tag] = Meta.new meta.merge :meta => true @plugins = Hash.new unless @plugins @plugins[tag] = create_metaplugin tag, meta, block @_time = { :start => Time.now } # if m[:benchmark] end
Private Instance Methods
create_metaplugin(tag,meta,block)
click to toggle source
Create a metaplugin (helper)
# File lib/naplug.rb, line 57 def create_metaplugin(tag,meta,block) module_eval do define_method "#{tag}".to_sym do; @plugins[tag]; end # <tag> methods for quick access to plugins define_method "#{tag}!".to_sym do; self.exec! tag; end # <tag>! methods to involke exec! on a given plugin end Plugin.new tag, block, meta.merge(:parent => self, :meta => true) end