Sha256: 848f5c43af82dbb706ddb351c13f38c67698bc20d5da3649342e8774985b5587

Contents?: true

Size: 540 Bytes

Versions: 36

Compression:

Stored size: 540 Bytes

Contents

require 'active_support/inflector'

class Module
  def last_name
    name.demodulize
  end
  alias_method :demodulize, :last_name
end

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

36 entries across 36 versions & 1 rubygems

Version Path
sugar-high-0.6.3 lib/sugar-high/module.rb
sugar-high-0.6.2.1 lib/sugar-high/module.rb
sugar-high-0.6.1 lib/sugar-high/module.rb
sugar-high-0.6.0 lib/sugar-high/module.rb
sugar-high-0.5.5 lib/sugar-high/module.rb
sugar-high-0.5.4 lib/sugar-high/module.rb
sugar-high-0.5.3 lib/sugar-high/module.rb
sugar-high-0.5.1 lib/sugar-high/module.rb
sugar-high-0.5.0 lib/sugar-high/module.rb
sugar-high-0.4.9.5 lib/sugar-high/module.rb
sugar-high-0.4.9.3 lib/sugar-high/module.rb
sugar-high-0.4.9.2 lib/sugar-high/module.rb
sugar-high-0.4.9.1 lib/sugar-high/module.rb
sugar-high-0.4.9 lib/sugar-high/module.rb
sugar-high-0.4.8 lib/sugar-high/module.rb
sugar-high-0.4.7 lib/sugar-high/module.rb
sugar-high-0.4.6.4 lib/sugar-high/module.rb
sugar-high-0.4.6.3 lib/sugar-high/module.rb
sugar-high-0.4.6.2 lib/sugar-high/module.rb
sugar-high-0.4.6.1 lib/sugar-high/module.rb