Sha256: b54981fea3382870e7f601e49b5dd4c15aa181807b519afbc2a885a744c84f79

Contents?: true

Size: 531 Bytes

Versions: 4

Compression:

Stored size: 531 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

4 entries across 4 versions & 1 rubygems

Version Path
sugar-high-0.7.3 lib/sugar-high/module.rb
sugar-high-0.7.2 lib/sugar-high/module.rb
sugar-high-0.7.1 lib/sugar-high/module.rb
sugar-high-0.7.0 lib/sugar-high/module.rb