Skip to content

Instantly share code, notes, and snippets.

@b4ldr
Last active May 28, 2020 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b4ldr/a63a95399ef6b6afd1df620124f19195 to your computer and use it in GitHub Desktop.
Save b4ldr/a63a95399ef6b6afd1df620124f19195 to your computer and use it in GitHub Desktop.
class Foo
@@count = 1
def self.count
@@count
end
def self.increment
@@count += 1
end
end
Puppet::Functions.create_function(:'test::foo') do
dispatch :foo do
end
def foo
Foo.increment
Foo.count
end
end
$ puppet apply ~/puppet_tests/ruby_classvar.pp
Notice: Scope(Class[main]): 2
Notice: Scope(Class[main]): 3
Notice: Compiled catalog for work-laptop.home.arpa in environment production in 0.01 seconds
Notice: Applied catalog in 0.01 seconds
notice(test::foo())
notice(test::foo())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment