module Haml::Util

def def_static_method(klass, name, args, *vars)

Parameters:
  • vars (Array) -- The names of the static boolean variables
  • args (Array) -- The names of the arguments to the defined methods
  • name (#to_s) -- The (base) name of the static method
  • klass (Module) -- The class on which to define the static method

Overloads:
  • def_static_method(klass, name, args, *vars, erb)
def def_static_method(klass, name, args, *vars)
  erb = vars.pop
  info = caller_info
  powerset(vars).each do |set|
    context = StaticConditionalContext.new(set).instance_eval {binding}
    method_content = (defined?(Erubis::TinyEruby) && Erubis::TinyEruby || ERB).new(erb).result(context)
    klass.class_eval(<<METHOD, info[0], info[1])
      def #{static_method_name(name, *vars.map {|v| set.include?(v)})}(#{args.join(', ')})
        #{method_content}
      end
OD
  end
end