Module: UsingYAML::InstanceMethods

Defined in:
lib/using_yaml.rb

Overview

Instance methods which allow us to define where YAML files are read/written from/to.

Instance Method Summary collapse

Instance Method Details

#using_yaml_pathObject

Reader which determines where to find files according to the following recipe:

(1) Load the :path option from +using_yaml+, if set
(2) Possibly invoke a Proc (if supplied to step 1)
(3) Default to the current location if 1 & 2 failed

You can, of course, overrite this method if you wish to supply your own logic.



174
175
176
177
178
179
180
# File 'lib/using_yaml.rb', line 174

def using_yaml_path
  return @using_yaml_path unless @using_yaml_path.nil?
  
  path = UsingYAML.path(self.class.name)
  path = path.call(self) if path.is_a? Proc
  @using_yaml_path = Pathname.new(path || '.')
end

#using_yaml_path=(path) ⇒ Object

Sets the YAML load path to the given argument by invoking Pathname.new on path.



184
185
186
# File 'lib/using_yaml.rb', line 184

def using_yaml_path=(path)
  @using_yaml_path = path && Pathname.new(path)
end