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.

Returns:

  • (String)

    Path to a directory for use with patch



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.

Returns:

  • (Object, nil)

    The current default safe level for ERb



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.

Returns:

  • (String, nil)

    The current default trim mode for ERb



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

Parameters:

  • name (#to_s)

    Name of a patch to load from the patch_dir

Returns:

  • (Patch)

    A patch loaded 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