def using_yaml_file(filename)
      # Define an reader for filename such that the corresponding
      # YAML file is loaded. Example: using_yaml_file(:foo) will look
      # for foo.yml in the specified path.
      define_method(filename) do
        # Work out the absolute path for the filename and get a handle
        # on the cachestore for that file.
        pathname = using_yaml_path.join("#{filename}.yml").expand_path
        yaml     = (@using_yaml_cache ||= {})[pathname]

        # If the yaml exists in our cache, then we don't need to hit
        # the disk.
        return yaml if @using_yaml_cache.has_key? pathname

        # Safe disk read which either reads and parses a YAML object
        # (and caches it against future reads) or graciously ignores
        # the file's existence. Note that an error will appear on
        # stderr to avoid typos (or similar) from causing unexpected
        # behavior. See +UsingYAML.squelch!+ if you wish to hide the
        # error.
        begin
          @using_yaml_cache[pathname] = UsingYAML.add_extensions(YAML.load_file(pathname), pathname)
        rescue Exception => e
          $stderr.puts "(UsingYAML) Could not load #{filename}: #{e.message}" unless UsingYAML.squelched?
          @using_yaml_cache[pathname] = UsingYAML.add_extensions(nil, pathname)
        end
      end

      # Define a writer for filename such that the incoming object is
      # treated as a UsingYAML-ized Hash (magical properties). Be
      # aware that the incoming object will not be saved to disk
      # unless you explicitly do so.
      define_method("#{filename}=".to_sym) do |object|
        # Work out the absolute path for the filename and get a handle
        # on the cachestore for that file.
        pathname = using_yaml_path.join("#{filename}.yml").expand_path
        (@using_yaml_cache ||= {})[pathname] = UsingYAML.add_extensions(object, pathname)
      end
    end
def using_yaml_file(filename)
      # Define an reader for filename such that the corresponding
      # YAML file is loaded. Example: using_yaml_file(:foo) will look
      # for foo.yml in the specified path.
      define_method(filename) do
        # Work out the absolute path for the filename and get a handle
        # on the cachestore for that file.
        pathname = using_yaml_path.join("#{filename}.yml").expand_path
        yaml     = (@using_yaml_cache ||= {})[pathname]

        # If the yaml exists in our cache, then we don't need to hit
        # the disk.
        return yaml if @using_yaml_cache.has_key? pathname

        # Safe disk read which either reads and parses a YAML object
        # (and caches it against future reads) or graciously ignores
        # the file's existence. Note that an error will appear on
        # stderr to avoid typos (or similar) from causing unexpected
        # behavior. See +UsingYAML.squelch!+ if you wish to hide the
        # error.
        begin
          @using_yaml_cache[pathname] = UsingYAML.add_extensions(YAML.load_file(pathname), pathname)
        rescue Exception => e
          $stderr.puts "(UsingYAML) Could not load #{filename}: #{e.message}" unless UsingYAML.squelched?
          @using_yaml_cache[pathname] = UsingYAML.add_extensions(nil, pathname)
        end
      end

      # Define a writer for filename such that the incoming object is
      # treated as a UsingYAML-ized Hash (magical properties). Be
      # aware that the incoming object will not be saved to disk
      # unless you explicitly do so.
      define_method("#{filename}=".to_sym) do |object|
        # Work out the absolute path for the filename and get a handle
        # on the cachestore for that file.
        pathname = using_yaml_path.join("#{filename}.yml").expand_path
        (@using_yaml_cache ||= {})[pathname] = UsingYAML.add_extensions(object, pathname)
      end
    end
Special attr_accessor for the suppiled +filename+ such that
 files are intelligently loaded/written to disk.

   using_yaml_file(:foo) # => attr_accessor(:foo) + some magic

 If class Example is setup with the above, then:

   example = Example.new
   example.foo      # => loads from foo.yml
   example.foo.bar  # => equivalent to example.foo['bar']
   example.foo.save # => serialises to foo.yml