Module: Lesmok::Acid::Meltable

Includes:
Helpers
Defined in:
lib/lesmok/acid/meltable.rb

Overview

Indicate that a model can be liquified.

Instance Method Summary collapse

Methods included from Helpers

#cast, #melt, #solid

Instance Method Details

#liquify_drop_klassObject

We expect Drop classes to be in same namespace as the object class.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/lesmok/acid/meltable.rb', line 44

def liquify_drop_klass
  str = self.class.name + 'Drop'
  klass = str.split('::').inject(Object) do |mod, class_name|
    mod.const_get(class_name)
  end
  klass
rescue NameError => err
  msg = "[#{self.class}] Could not find liquid drop class..."
  ::Lesmok.logger.warn(msg) if Lesmok.config.debugging?
  Drop
end

#liquify_dynamicallyObject

Fallback to trying to find the drop class dynamically or use generic AcidDrop if it can’t be found.



35
36
37
38
39
# File 'lib/lesmok/acid/meltable.rb', line 35

def liquify_dynamically
  return @liquid_drop if @liquid_drop
  klass = liquify_drop_klass || AcidDrop
  @liquid_drop = klass.new(self)
end

#to_liquidObject

Liquify…



22
23
24
# File 'lib/lesmok/acid/meltable.rb', line 22

def to_liquid
  @liquid_drop ||= liquify_dynamically
end

#to_solidObject

Solidify



27
28
29
# File 'lib/lesmok/acid/meltable.rb', line 27

def to_solid
  self
end