diff --git a/lib/puppet/string/action.rb b/lib/puppet/string/action.rb index 4db9e97e2..5a7f3f203 100644 --- a/lib/puppet/string/action.rb +++ b/lib/puppet/string/action.rb @@ -1,26 +1,30 @@ require 'puppet/string' class Puppet::String::Action attr_reader :name + def to_s + "#{@string}##{@name}" + end + def initialize(string, name, attrs = {}) name = name.to_s raise "'#{name}' is an invalid action name" unless name =~ /^[a-z]\w*$/ @string = string @name = name attrs.each do |k,v| send("#{k}=", v) end end def invoke(*args, &block) @string.method(name).call(*args,&block) end def invoke=(block) if @string.is_a?(Class) @string.define_method(@name, &block) else @string.meta_def(@name, &block) end end end