Sha256: 791008bb2728e001e46dcc14a6e540bca587105cbbaf3b7ca8885ff529a3b41d
Contents?: true
Size: 618 Bytes
Versions: 2
Compression:
Stored size: 618 Bytes
Contents
module Outbox module DefineInheritableMethod # Similar to .define_method, but adds a dynamic module in the inheritance # change to attach the method to. See: # # http://thepugautomatic.com/2013/07/dsom/ def define_inheritable_method(mod_name, *args, &block) mod = get_inheritable_module(mod_name) mod.module_eval do define_method(*args, &block) end end protected def get_inheritable_module(mod_name) if const_defined?(mod_name, false) const_get(mod_name) else include const_set(mod_name, Module.new) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
outbox-0.2.1 | lib/outbox/define_inheritable_method.rb |
outbox-0.2.0 | lib/outbox/define_inheritable_method.rb |