Sha256: 0e956fda71c1a5c7435b33f4602207c32797cc2e4df8b0ed2da11687072fb681

Contents?: true

Size: 441 Bytes

Versions: 4

Compression:

Stored size: 441 Bytes

Contents

require 'active_support/inflector'

def modules *module_names, &block
  module_names.flatten.each do |name|
    class_eval %{
      module #{name.to_s.camelize}
        #{yield block if block}
      end
    }    
  end
end 

def nested_modules *module_names, &block
  module_names.flatten.inject([]) do |res, name|  
    res << %{
      module #{name.to_s.camelize}
        #{yield block if block}
      end}  
  end.flatten.join("\n")
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sugar-high-0.1.5 lib/sugar-high/module.rb
sugar-high-0.1.4 lib/sugar-high/module.rb
sugar-high-0.1.2 lib/sugar-high/module.rb
sugar-high-0.1.1 lib/sugar-high/module.rb