2015-08-28 18:49:21 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
module Vulcano
|
|
|
|
module Plugins
|
|
|
|
class Resource
|
2015-09-05 14:07:54 +00:00
|
|
|
def self.name(name)
|
2015-08-28 18:49:21 +00:00
|
|
|
Vulcano::Plugins::Resource.__register(name, self)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.__register(name, obj)
|
2015-09-09 07:42:46 +00:00
|
|
|
# rubocop:disable Lint/NestedMethodDefinition
|
2015-08-28 18:49:21 +00:00
|
|
|
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
|
2015-09-06 18:35:41 +00:00
|
|
|
@__backend_runner__ = backend
|
2015-08-30 02:33:15 +00:00
|
|
|
# call the resource initializer
|
2015-08-28 18:49:21 +00:00
|
|
|
super(*args)
|
|
|
|
end
|
2015-09-06 18:35:41 +00:00
|
|
|
|
|
|
|
def vulcano
|
|
|
|
@__backend_runner__
|
|
|
|
end
|
2015-08-28 18:49:21 +00:00
|
|
|
end
|
2015-09-09 07:42:46 +00:00
|
|
|
# rubocop:enable Lint/NestedMethodDefinition
|
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
|
|
|
|
|
2015-09-05 14:07:54 +00:00
|
|
|
def skip_resource(message)
|
2015-08-28 18:49:21 +00:00
|
|
|
@resource_skipped = message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|