lib/poolparty/poolparty/resource.rb in auser-poolparty-1.2.2 vs lib/poolparty/poolparty/resource.rb in auser-poolparty-1.2.3
- old
+ new
@@ -59,10 +59,11 @@
end
public
EOE
PoolParty::PoolPartyBaseClass.module_eval method
PoolParty::PoolPartyBaseClass.add_has_and_does_not_have_methods_for(lowercase_class_name.to_sym)
+ PoolParty::PoolPartyBaseClass.add_resource_lookup_method(lowercase_class_name)
available_resources << subclass
end
end
@@ -70,23 +71,31 @@
# later and ensure that we are only calling available resources
def self.available_resources
@available_resources ||= []
end
+ dsl_methods :action,
+ :not_if,
+ :if_not,
+ :only_if,
+ :calls,
+ :requires
+
# This is set in order of descending precedence
# The options are overwritten from the bottom up
# and the resource will use those as the values
# Then it takes the value of the block and sets whatever is sent there as
# the options
# Finally, it uses the parent's options as the lowest priority
def initialize(opts={}, extra_opts={}, &block)
super(opts, extra_opts, &block)
-
+
@resource_name = @base_name
- dsl_options[:name] = resource_name unless dsl_options.has_key?(:name)
+ # dsl_options[:name] = @init_opts[:name] unless dsl_options.has_key?(:name) && dsl_options[:name]
- loaded(opts, &block)
+ # p [:name, name, dsl_options, init_opts] # methods.sort.join(", ")
+ loaded(init_opts, &block)
after_create
end
# Stub, so you can create virtual resources
@@ -96,18 +105,18 @@
end
def resource_name
@resource_name ||= nil
end
-
- def name(*args)
- resource_name
- end
-
+
# After create callback
def after_create
end
+ def before_load(o={}, &block)
+ end
+ def after_load(o={}, &block)
+ end
# We don't want to inherit the services on a resource, as resources
# are a base and should never have services.
def services
end
@@ -127,37 +136,10 @@
end
# This way we can subclass resources without worry
def class_type_name
self.class.to_s.top_level_class.underscore.downcase
end
- def self.custom_function(str)
- custom_functions << str
- end
- def self.custom_functions
- @custom_functions ||= []
- end
- def custom_function(str)
- self.class.custom_functions << str
- end
-
- def self.custom_functions_to_string(pre="")
- returning Array.new do |output|
- PoolParty::Resources.available_custom_resources.each do |resource|
- resource.custom_functions.each do |func|
- output << "#{pre*2}#{func}"
- end
- end
- end.join("\n")
- end
- # Some things in puppet aren't allowed, so let's override them here
- def disallowed_options
- []
- end
-
- def key
- name
- end
# def virtual_resource?
# false
# end
# def printable?
# true
@@ -168,18 +150,10 @@
def is_a_resource?
true
end
- def method_missing(m,*a,&block)
- if parent && parent.dsl_options.has_key?(m) && is_in_plugin?
- parent.send m, *a, &block
- else
- super
- end
- end
-
# Private method just for resource retrievling purposes
def class_name_sym
self.class.to_s.top_level_class.downcase.to_sym
end
# We want to gather the options, but if the option sent is nil
@@ -208,6 +182,6 @@
end
end
end
-Dir["#{::File.dirname(__FILE__)}/../resources/*.rb"].each {|lib| require "#{lib}"}
\ No newline at end of file
+Dir["#{::File.dirname(__FILE__)}/../resources/*.rb"].each {|lib| require "#{lib}"}