Module: StateFu::ModuleRefArray

Included in:
HelperArray, ToolArray
Defined in:
lib/support/arrays.rb

Instance Method Summary collapse

Instance Method Details

#inject_into(obj) ⇒ Object

modules



131
132
133
134
135
136
137
138
139
# File 'lib/support/arrays.rb', line 131

def inject_into( obj )
  metaclass = class << obj; self; end
  mods = self.modules()
  metaclass.class_eval do
    mods.each do |mod|
      include( mod )
    end
  end
end

#modulesObject



116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/support/arrays.rb', line 116

def modules
  self.map do |h|
    case h
    when String, Symbol
      mod_name = h.to_s.split('/').inject(Object) do |mod, part|
        mod = mod.const_get( part.camelize )
      end
    when Module
      h
    else
      raise ArgumentError.new( h.class.inspect )
    end
  end
end