2015-08-28 18:49:21 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
module Vulcano
|
|
|
|
module Plugins
|
|
|
|
|
|
|
|
class Resource
|
|
|
|
def self.name( name )
|
|
|
|
Vulcano::Plugins::Resource.__register(name, self)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.__register(name, obj)
|
|
|
|
cl = Class.new(obj) do
|
2015-08-30 02:33:15 +00:00
|
|
|
# add some common methods
|
2015-08-28 18:49:21 +00:00
|
|
|
include Vulcano::Plugins::ResourceCommon
|
|
|
|
def initialize(backend, *args)
|
2015-08-30 02:33:15 +00:00
|
|
|
# attach the backend to this instance
|
|
|
|
self.class.send(:define_method, :vulcano){backend}
|
|
|
|
# call the resource initializer
|
2015-08-28 18:49:21 +00:00
|
|
|
super(*args)
|
|
|
|
end
|
|
|
|
end
|
2015-08-30 02:33:15 +00:00
|
|
|
|
|
|
|
# add the resource to the registry by name
|
2015-08-28 18:49:21 +00:00
|
|
|
Vulcano::Resource.registry[name] = cl
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module ResourceCommon
|
|
|
|
def resource_skipped
|
|
|
|
@resource_skipped
|
|
|
|
end
|
|
|
|
|
|
|
|
def skip_resource message
|
|
|
|
@resource_skipped = message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|