summaryrefslogtreecommitdiff
path: root/lib/chef/dsl/resources.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-05-02 00:11:40 -0700
committerJohn Keiser <john@johnkeiser.com>2015-05-13 13:43:14 -0700
commit8e09b80cbeeef8a1a396434bec9dc76737061b13 (patch)
treed1f6553fb27141088bcbd2b50c5faead8251ce26 /lib/chef/dsl/resources.rb
parent200934f63c02c2b70532eb8a010337ac3b8e9803 (diff)
downloadchef-8e09b80cbeeef8a1a396434bec9dc76737061b13.tar.gz
Move LWRP class deprecation warning to const_missing
Diffstat (limited to 'lib/chef/dsl/resources.rb')
-rw-r--r--lib/chef/dsl/resources.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/chef/dsl/resources.rb b/lib/chef/dsl/resources.rb
index 482b14e3aa..4072ff2c89 100644
--- a/lib/chef/dsl/resources.rb
+++ b/lib/chef/dsl/resources.rb
@@ -8,14 +8,20 @@ class Chef
# @api private
module Resources
def self.add_resource_dsl(dsl_name)
- module_eval <<-EOM, __FILE__, __LINE__+1
- def #{dsl_name}(name, created_at=nil, &block)
- declare_resource(#{dsl_name.inspect}, name, created_at || caller[0], &block)
+ begin
+ module_eval(<<-EOM, __FILE__, __LINE__+1)
+ def #{dsl_name}(name, created_at=nil, &block)
+ declare_resource(#{dsl_name.inspect}, name, created_at || caller[0], &block)
+ end
+ EOM
+ rescue SyntaxError
+ define_method(dsl_name.to_sym) do |name, created_at=nil, &block|
+ declare_resource(dsl_name, name, created_at || caller[0], &block)
end
- EOM
+ end
end
def self.remove_resource_dsl(dsl_name)
- remove_method dsl_name if method_defined?(dsl_name)
+ remove_method(dsl_name) if method_defined?(dsl_name)
end
end
end