Skip to content

Instantly share code, notes, and snippets.

@ljsc
Created February 12, 2010 17:11
Show Gist options
  • Save ljsc/302762 to your computer and use it in GitHub Desktop.
Save ljsc/302762 to your computer and use it in GitHub Desktop.
require 'pp'
class Foo
def parameterfest(one, two, subopts, opts)
puts "One: #{one}"
puts "Two: #{two}"
puts "Subopts: #{subopts.pretty_print_inspect}"
puts "Opts: #{opts.pretty_print_inspect}"
end
end
class PFestParameters
def initialize
yield self
end
def one(o)
@one = o
end
def two(t)
@two = t
end
def sub(opts)
@sub = opts
end
def opts(opts)
@opts = opts
end
def to_a
[@one, @two, @sub, @opts]
end
end
params = PFestParameters.new do |p|
p.one "1"
p.two "2"
p.sub :a => 'A', :b => 'B'
p.opts :z => 'Z'
end
foo = Foo.new
foo.parameterfest(*params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment