Module: Solid::LiquidExtensions::ClassHighjacker

Included in:
Variable
Defined in:
lib/solid/liquid_extensions.rb

Instance Method Summary collapse

Instance Method Details

#demodulized_nameObject



28
29
30
# File 'lib/solid/liquid_extensions.rb', line 28

def demodulized_name
  @demodulized_name ||= self.name.split('::').last
end

#load!Object



15
16
17
18
19
# File 'lib/solid/liquid_extensions.rb', line 15

def load!
  original_class = Liquid.send(:remove_const, demodulized_name)
  original_classes[demodulized_name] = original_class unless original_classes.has_key?(demodulized_name) # avoid loosing reference to original class
  Liquid.const_set(demodulized_name, self)
end

#unload!Object



21
22
23
24
25
26
# File 'lib/solid/liquid_extensions.rb', line 21

def unload!
  if original_class = original_classes[demodulized_name]
    Liquid.send(:remove_const, demodulized_name)
    Liquid.const_set(demodulized_name, original_class)
  end
end