Skip to content

Instantly share code, notes, and snippets.

@kohsuke
Created March 22, 2012 15:44
Show Gist options
  • Save kohsuke/2159107 to your computer and use it in GitHub Desktop.
Save kohsuke/2159107 to your computer and use it in GitHub Desktop.
require 'jenkins/plugin/behavior'
module Jenkins
#
# Defines the equivalent of `hudson.Extension`
#
module Extension
extend Plugin::Behavior
implemented do |cls|
puts "kicking in for #{cls}"
cls.instance_eval do
def self.ordinal(n=nil)
if n.nil?
@ordinal
else
@ordinal = n
end
end
end
end
end
class Foo
include Extension
ordinal 3
end
class Bar
include Extension
ordinal 5
end
puts Bar.ordinal
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment