Top Level Namespace
Defined Under Namespace
Modules: Poise
Instance Method Summary collapse
-
#Poise(options = {}) ⇒ Object
Callable form to allow passing in options: include Poise(ParentResource) include Poise(parent: ParentResource) include Poise(container: true).
Instance Method Details
#Poise(options = {}) ⇒ Object
Callable form to allow passing in options: include Poise(ParentResource) include Poise(parent: ParentResource) include Poise(container: true)
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/poise.rb', line 70 def Poise(={}) # Allow passing a class as a shortcut if .is_a?(Class) || .is_a?(Symbol) = {parent: } end # Create a new anonymous module mod = Module.new # Fake the name. mod.define_singleton_method(:name) do super() || 'Poise' end mod.define_singleton_method(:included) do |klass| super(klass) # Pull in the main helper to cover most of the needed logic. klass.class_exec { include Poise } # Set the defined_in values as needed. klass.poise_defined!(caller) # Resource-specific options. if klass < Chef::Resource klass.poise_subresource([:parent], [:parent_optional], [:parent_auto]) if [:parent] klass.poise_subresource_container([:container_namespace], [:container_default]) if [:container] klass.poise_fused if [:fused] klass.poise_inversion([:inversion_options_resource]) if [:inversion] end # Provider-specific options. if klass < Chef::Provider klass.poise_inversion([:inversion], [:inversion_attribute]) if [:inversion] end end mod end |