Created
March 22, 2012 15:44
-
-
Save kohsuke/2159107 to your computer and use it in GitHub Desktop.
This file contains 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 characters
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