Skip to content

Commit

Permalink
Merge pull request #179 from k0kubun/autoload-plugin
Browse files Browse the repository at this point in the history
Fallback to autoload resource plugin
  • Loading branch information
ryotarai committed Dec 6, 2015
2 parents 0c84365 + a49c94c commit 52878a5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/itamae/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,20 @@ def get_resource_class(method)
begin
::Itamae::Plugin::Resource.const_get(to_camel_case(method.to_s))
rescue NameError
raise Error, "#{method} resource is missing."
autoload_plugin_resource(method)
end
end
end

def autoload_plugin_resource(method)
begin
require "itamae/plugin/resource/#{method}"
::Itamae::Plugin::Resource.const_get(to_camel_case(method.to_s))
rescue LoadError, NameError
raise Error, "#{method} resource is missing."
end
end

def define_resource(name, klass)
class_name = to_camel_case(name.to_s)
if Resource.const_defined?(class_name)
Expand Down

0 comments on commit 52878a5

Please sign in to comment.