module SimpleColor::Mixin
Public Class Methods
define_color_methods(klass, *methods, opts_from: nil, color_module: ColorWrapper)
click to toggle source
# File lib/simplecolor.rb, line 184 def self.define_color_methods(klass, *methods, opts_from: nil, color_module: ColorWrapper) methods=color_module.instance_methods if methods.empty? methods.each do |m| # klass.define_method m do |*args, **l_opts, &b| klass.class_eval do define_method m do |*args, **l_opts, &b| opts= opts_from ? opts_from.opts : self.opts opts=opts.merge(l_opts) color_module.instance_method(m).bind(self).call(*args, **opts, &b) end end end end
Public Instance Methods
mix_in(klass)
click to toggle source
# File lib/simplecolor.rb, line 205 def mix_in(klass) klass.send :include, mixin end
mix_in_string()
click to toggle source
# File lib/simplecolor.rb, line 208 def mix_in_string mix_in(String) end
mixin(*methods)
click to toggle source
# File lib/simplecolor.rb, line 198 def mixin(*methods) klass=self Module.new do Mixin.define_color_methods(self, *methods, opts_from: klass) end end