Module: DuckPuncher::Ducks

Defined in:
lib/duck_puncher/ducks.rb,
lib/duck_puncher/ducks/hash.rb,
lib/duck_puncher/ducks/method.rb,
lib/duck_puncher/ducks/module.rb,
lib/duck_puncher/ducks/object.rb,
lib/duck_puncher/ducks/string.rb,
lib/duck_puncher/ducks/numeric.rb,
lib/duck_puncher/ducks/enumerable.rb,
lib/duck_puncher/ducks/active_record.rb

Defined Under Namespace

Modules: ActiveRecord, Enumerable, Hash, Method, Module, Numeric, Object, String

Class Method Summary collapse

Class Method Details

.[](klass) ⇒ Object



17
18
19
# File 'lib/duck_puncher/ducks.rb', line 17

def [](klass)
  list[klass]
end

.listObject



13
14
15
# File 'lib/duck_puncher/ducks.rb', line 13

def list
  @list ||= DuckPuncher.ancestral_hash
end

.load_mods(klass, loaded_mods: []) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/duck_puncher/ducks.rb', line 21

def load_mods(klass, loaded_mods: [])
  if klass.respond_to?(:superclass)
    load_mods(klass.superclass, loaded_mods: list[klass].to_a.map(&:mod) + loaded_mods)
  else
    loaded_mods
  end
end