Sha256: cc681793477cf59d943844c022409dcc34aebe9e58a508e761cd444b82e1ce6f

Contents?: true

Size: 570 Bytes

Versions: 15

Compression:

Stored size: 570 Bytes

Contents

require 'active_support/inflector'

class Module
  def last_name
    # name.gsub /^(.*)::/, ''
    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

15 entries across 15 versions & 1 rubygems

Version Path
sugar-high-0.2.12 lib/sugar-high/module.rb
sugar-high-0.2.11 lib/sugar-high/module.rb
sugar-high-0.2.10 lib/sugar-high/module.rb
sugar-high-0.2.9 lib/sugar-high/module.rb
sugar-high-0.2.8 lib/sugar-high/module.rb
sugar-high-0.2.7 lib/sugar-high/module.rb
sugar-high-0.2.6 lib/sugar-high/module.rb
sugar-high-0.2.5 lib/sugar-high/module.rb
sugar-high-0.2.4 lib/sugar-high/module.rb
sugar-high-0.2.2 lib/sugar-high/module.rb
sugar-high-0.2.1 lib/sugar-high/module.rb
sugar-high-0.2.0 lib/sugar-high/module.rb
sugar-high-0.1.8 lib/sugar-high/module.rb
sugar-high-0.1.7 lib/sugar-high/module.rb
sugar-high-0.1.6 lib/sugar-high/module.rb