Module: EasyType::Parameter::ClassMethods
- Defined in:
- lib/easy_type/parameter.rb
Instance Method Summary collapse
-
#after_apply(&block) ⇒ Object
a property callback that alows you to do certain actions after the resource is actualy created or modified.
-
#after_create(&block) ⇒ Object
a property callback that alows you to do certain actions after the resource is actualy created.
-
#after_destroy(&block) ⇒ Object
a property callback that allows you to do certain actions after the resource is actualy destroyed.
-
#after_modify(&block) ⇒ Object
a property callback that alows you to do certain actions after the resource is actualy modfied.
-
#before_apply(&block) ⇒ Object
a property callback that alows you to do certain actions before the resource is actualy created or modified.
-
#before_create(&block) ⇒ Object
a property callback that alows you to do certain actions before the resource is actualy created.
-
#before_destroy(&block) ⇒ Object
is actualy destroyed.
-
#before_modify(&block) ⇒ Object
a property callback that alows you to do certain actions before the resource is actualy modfied.
- #called_before(method_name) ⇒ Object
-
#coerce(value) ⇒ Object
Basic implementation for coercing a value to the correct type.
-
#data_type(_type_string) ⇒ Object
This method is needed to support legacy puppet versions which do not support munging in Puppet::ResourceApi.
- #fail_if_competing_method_defined ⇒ Object
-
#on_apply(&block) ⇒ Object
retuns the string needed to modify this specific property of a defined type.
-
#on_create(&block) ⇒ Object
retuns the string needed to create this specific property of a defined type.
-
#on_destroy(&block) ⇒ Object
a property callback that allows you to do certain actionsin the destroy sequence.
-
#on_modify(&block) ⇒ Object
retuns the string needed to modify this specific property of a defined type.
-
#to_translate_to_resource(&block) ⇒ Object
maps a raw resource to retuns the string needed to modify this specific property of a type.
Instance Method Details
#after_apply(&block) ⇒ Object
a property callback that alows you to do certain actions after the resource is actualy created or modified.
96 97 98 |
# File 'lib/easy_type/parameter.rb', line 96 def after_apply(&block) define_method(:after_apply, &block) if block end |
#after_create(&block) ⇒ Object
a property callback that alows you to do certain actions after the resource is actualy created.
144 145 146 |
# File 'lib/easy_type/parameter.rb', line 144 def after_create(&block) define_method(:after_create, &block) if block end |
#after_destroy(&block) ⇒ Object
a property callback that allows you to do certain actions after the resource is actualy destroyed.
245 246 247 |
# File 'lib/easy_type/parameter.rb', line 245 def after_destroy(&block) define_method(:after_destroy, &block) if block end |
#after_modify(&block) ⇒ Object
a property callback that alows you to do certain actions after the resource is actualy modfied.
188 189 190 |
# File 'lib/easy_type/parameter.rb', line 188 def after_modify(&block) define_method(:after_modify, &block) if block end |
#before_apply(&block) ⇒ Object
a property callback that alows you to do certain actions before the resource is actualy created or modified.
72 73 74 |
# File 'lib/easy_type/parameter.rb', line 72 def before_apply(&block) define_method(:before_apply, &block) if block end |
#before_create(&block) ⇒ Object
a property callback that alows you to do certain actions before the resource is actualy created.
120 121 122 |
# File 'lib/easy_type/parameter.rb', line 120 def before_create(&block) define_method(:before_create, &block) if block end |
#before_destroy(&block) ⇒ Object
is actualy destroyed.
207 208 209 |
# File 'lib/easy_type/parameter.rb', line 207 def before_destroy(&block) define_method(:before_destroy, &block) if block end |
#before_modify(&block) ⇒ Object
a property callback that alows you to do certain actions before the resource is actualy modfied.
168 169 170 |
# File 'lib/easy_type/parameter.rb', line 168 def before_modify(&block) define_method(:before_modify, &block) if block end |
#called_before(method_name) ⇒ Object
263 264 265 |
# File 'lib/easy_type/parameter.rb', line 263 def called_before(method_name) method_defined? method_name end |
#coerce(value) ⇒ Object
Basic implementation for coercing a value to the correct type.
252 253 254 |
# File 'lib/easy_type/parameter.rb', line 252 def coerce(value) value end |
#data_type(_type_string) ⇒ Object
This method is needed to support legacy puppet versions which do not support munging in Puppet::ResourceApi. It returns nil.
26 27 28 |
# File 'lib/easy_type/parameter.rb', line 26 def data_type(_type_string) nil end |
#fail_if_competing_method_defined ⇒ Object
257 258 259 260 261 |
# File 'lib/easy_type/parameter.rb', line 257 def fail_if_competing_method_defined %w(on_create on_modify).each do |method_name| raise "method #{method_name} can not coexist with on_apply. Use one or the other" if called_before(method_name) end end |
#on_apply(&block) ⇒ Object
retuns the string needed to modify this specific property of a defined type
47 48 49 50 |
# File 'lib/easy_type/parameter.rb', line 47 def on_apply(&block) fail_if_competing_method_defined define_method(:on_apply, &block) if block end |
#on_create(&block) ⇒ Object
retuns the string needed to create this specific property of a defined type. This method is ONLY called when the resource is created. It is not allowed to have both an ‘on_apply` and a `on_create` definition on the type.
286 287 288 |
# File 'lib/easy_type/parameter.rb', line 286 def on_create(&block) define_method(:on_create, &block) if block end |
#on_destroy(&block) ⇒ Object
a property callback that allows you to do certain actionsin the destroy sequence
225 226 227 |
# File 'lib/easy_type/parameter.rb', line 225 def on_destroy(&block) define_method(:on_destroy, &block) if block end |
#on_modify(&block) ⇒ Object
retuns the string needed to modify this specific property of a defined type. This method is ONLY called when the resource is modified. It is not allowed to have both an ‘on_apply` and a `on_destroy` definition on the type.
309 310 311 |
# File 'lib/easy_type/parameter.rb', line 309 def on_modify(&block) define_method(:on_modify, &block) if block end |
#to_translate_to_resource(&block) ⇒ Object
maps a raw resource to retuns the string needed to modify this specific property of a type
327 328 329 330 |
# File 'lib/easy_type/parameter.rb', line 327 def to_translate_to_resource(&block) eigenclass = class << self; self; end eigenclass.send(:define_method, :translate_to_resource, &block) end |