From 8d3673d5df4f09909f092c5cb42ef8870762db1a Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 23 Apr 2007 18:01:36 +0000 Subject: Adding a :block_eval option to FileRecords in FileParsing, so ParsedFile providers can have records just define a bunch of methods at once, rather than using lots of hooks. This is cleaner when custom parse and generate methods are used. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2407 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/util/fileparsing.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb index c11645bfb..169320ae5 100644 --- a/lib/puppet/util/fileparsing.rb +++ b/lib/puppet/util/fileparsing.rb @@ -33,8 +33,7 @@ module Puppet::Util::FileParsing class FileRecord include Puppet::Util include Puppet::Util::MethodHelper - attr_accessor :absent, :joiner, :rts, - :separator, :rollup, :name, :match + attr_accessor :absent, :joiner, :rts, :separator, :rollup, :name, :match, :block_eval attr_reader :fields, :optional, :type @@ -71,7 +70,14 @@ module Puppet::Util::FileParsing end if block_given? - meta_def(:process, &block) + @block_eval ||= :process + + # Allow the developer to specify that a block should be instance-eval'ed. + if @block_eval == :instance + instance_eval(&block) + else + meta_def(@block_eval, &block) + end end end -- cgit