summaryrefslogtreecommitdiffstats
path: root/lib/puppet/interface/action.rb
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-03-22 12:54:52 -0700
committerNick Lewis <nick@puppetlabs.com>2011-03-22 14:16:32 -0700
commite3d24865c89bccd0221f3d6d475d350f577ed3fb (patch)
tree01e2f42e8342767aa7f9e63e961a61bb81046b98 /lib/puppet/interface/action.rb
parent45613e0f192778cd16f945d5d1eb109e6c8dee2d (diff)
downloadpuppet-e3d24865c89bccd0221f3d6d475d350f577ed3fb.tar.gz
puppet-e3d24865c89bccd0221f3d6d475d350f577ed3fb.tar.xz
puppet-e3d24865c89bccd0221f3d6d475d350f577ed3fb.zip
(#6814) Create a dedicated Action class
This class will represents an action, and allows us to store metadata for an action, and programmatically introspect and invoke them. A helper class ActionBuilder represents the DSL for defining an action. Also defined an "invoke" DSL method to handle the functionality of defining the method for an action. Reviewed-By: Daniel Pittman
Diffstat (limited to 'lib/puppet/interface/action.rb')
-rw-r--r--lib/puppet/interface/action.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb
new file mode 100644
index 000000000..e4c2a4666
--- /dev/null
+++ b/lib/puppet/interface/action.rb
@@ -0,0 +1,16 @@
+require 'puppet/interface'
+
+class Puppet::Interface::Action
+ attr_reader :name
+
+ def initialize(interface, name)
+ name = name.to_s
+ raise "'#{name}' is an invalid action name" unless name =~ /^[a-z]\w*$/
+ @interface = interface
+ @name = name
+ end
+
+ def invoke(*args, &block)
+ @interface.method(name).call(*args,&block)
+ end
+end