Method: UsingYAML::ClassMethods#using_yaml
- Defined in:
- lib/using_yaml.rb
#using_yaml(*args) ⇒ Object
Used to configure UsingYAML for a class by defining what files should be loaded and from where.
include UsingYAML
using_yaml :foo, :bar, :path => "/some/where"
args can contain either filenames or a hash which specifices a path which contains the corresponding files.
The value of :path must either be a string or Proc (see using_yaml_path for more information on overriding paths).
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/using_yaml.rb', line 101 def using_yaml(*args) # Include the instance methods which provide accessors and # mutators for reading/writing from/to the YAML objects. include InstanceMethods # Each argument is either a filename or a :path option args.each do |arg| case arg when Symbol, String # Define accessors for this file using_yaml_file(arg.to_s) when Hash # Currently only accepts { :path => ... } next unless arg.size == 1 && arg.keys.first == :path # Take note of the path UsingYAML.path = [self.inspect, arg.values.first] end end end |