Module: PatternPatch::Methods

Extended by:
Forwardable
Included in:
PatternPatch
Defined in:
lib/pattern_patch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#patch_dirString

Set this to conveniently load patches from a common folder with the patch method.



27
28
29
# File 'lib/pattern_patch.rb', line 27

def patch_dir
  @patch_dir
end

#safe_levelObject?

Set the default safe level to use with ERb. This is the same as the value of PatternPatch.safe_level.



33
# File 'lib/pattern_patch.rb', line 33

def_delegator "PatternPatch", :safe_level, :safe_level

#trim_modeString?

Set the default trim mode to use with ERb. This is the same as the value of PatternPatch.trim_mode.



40
# File 'lib/pattern_patch.rb', line 40

def_delegator "PatternPatch", :trim_mode, :trim_mode

Instance Method Details

#patch(name) ⇒ Patch

Loads a patch from the patch_dir

Raises:



47
48
49
50
51
# File 'lib/pattern_patch.rb', line 47

def patch(name)
  raise ConfigurationError, "patch_dir has not been set" if patch_dir.nil?
  raise ConfigurationError, "patch_dir is not a directory" unless Dir.exist?(patch_dir)
  Patch.from_yaml File.join(patch_dir, "#{name}.yml")
end