Sha256: 1dcd1e75dd38a0cb8f12960a3a3a6570dba0d711d21a49c742b44f74d923b94c

Contents?: true

Size: 572 Bytes

Versions: 4

Compression:

Stored size: 572 Bytes

Contents

class Class
  def include_and_extend(the_module, options={})
    options[:instance_methods] ||= :InstanceMethods
    options[:class_methods] ||= :ClassMethods
    # Mainly include but be flexible
    main_module = const_get(the_module)
    include main_module # for an extend_and_include method, change this to extend main_module
    include main_module.const_get(options[:instance_methods]) if main_module.const_defined?(options[:instance_methods])
    extend main_module.const_get(options[:class_methods]) if main_module.const_defined?(options[:class_methods])
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sugar-high-0.4.4.2 lib/sugar-high/class_ext.rb
sugar-high-0.4.4.1 lib/sugar-high/class_ext.rb
sugar-high-0.4.4 lib/sugar-high/class_ext.rb
sugar-high-0.4.3 lib/sugar-high/class_ext.rb