Sha256: fb548e245de3fcecc4ba867d4fc4b4bc84e2688ce960be2271a5ba2135442454
Contents?: true
Size: 637 Bytes
Versions: 2
Compression:
Stored size: 637 Bytes
Contents
require 'miu' module Miu module Plugin def self.included(base) STDOUT.sync = true STDERR.sync = true base.extend ClassMethods base.called_from = begin call_stack = caller.map { |p| p.sub(/:\d+.*/, '') } File.dirname(call_stack.detect { |p| p !~ %r(miu[\w.-]*/lib/miu/plugins) }) end end module ClassMethods attr_accessor :called_from def register(*args, &block) options = args.last.is_a?(::Hash) ? args.pop : {} name = args.shift plugin = args.shift || self Miu.register name, plugin, options, &block end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
miu-0.0.6 | lib/miu/plugin.rb |
miu-0.0.5 | lib/miu/plugin.rb |