Last active
January 30, 2020 15:52
-
-
Save hlindberg/e033ab9c8e20282cc494db6f04afc308 to your computer and use it in GitHub Desktop.
Revisions
-
hlindberg revised this gist
Jan 30, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ # The latch function remembers what it was called with # and returns what it was previously called with. # # This is using global namespace - in your code use a module namespace # -
hlindberg created this gist
Jan 30, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ # The latch function remembers what it was called with # and returns what it was previous called with. # # This is using global namespace - in your code use a module namespace # Puppet::Functions.create_function(:latch) do dispatch :example do repeated_param 'Any', :arg end def example(*args) adapter = adapterclass.adapt(closure_scope().compiler) result = adapter.thing adapter.thing = args result end def adapterclass @adapterclass ||= Class.new(Puppet::Pops::Adaptable::Adapter) do attr_accessor :thing def self.name() # This is using global namespace - in your code use a module namespace "LatchFunctionAdapter" end end @adapterclass end end