class Cardio::Mod::LoadStrategy

The main way to enhance cards’ appearance and behavior is through the card set DSL.

The default mechanism for loading DSL code is live evaluation, or Eval. Eval is fast and efficient and preferred for a wide range of scenarios, including production and live debugging. But Eval is problematic for generating both test coverage reports with Simplecov and documentation sites with YARD.

For those two reasons, we make it possible to load the DSL code by generating fully explicit ruby modules in tmp files.

Shared code for the three different load strategies: Eval, TmpFiles and BindingMagic

Attributes

current[RW]
tmp_files[RW]
loader[R]

Public Class Methods

class_for_set(strategy) click to toggle source
# File lib/cardio/mod/load_strategy.rb, line 18
def class_for_set strategy
  case strategy
  when :tmp_files then SetTmpFiles
  when :binding_magic then SetBindingMagic
  else Eval
  end
end
class_for_set_pattern(strategy) click to toggle source
# File lib/cardio/mod/load_strategy.rb, line 26
def class_for_set_pattern strategy
  strategy == :tmp_files ? PatternTmpFiles : Eval
end
new(loader) click to toggle source
# File lib/cardio/mod/load_strategy.rb, line 39
def initialize loader
  LoadStrategy.current = self.class
  @loader = loader
end
tmp_files?() click to toggle source
# File lib/cardio/mod/load_strategy.rb, line 30
def tmp_files?
  Cardio.config.load_strategy == :tmp_files
end

Public Instance Methods

clean_comments?() click to toggle source
# File lib/cardio/mod/load_strategy.rb, line 44
def clean_comments?
  false
end