Skip to content

Commit

Permalink
Fix Controller.required_option overriding methods in 1.9.
Browse files Browse the repository at this point in the history
In Ruby 1.9 the return value of `instance_methods` changed from an array
of strings to an array of symbols. So the collision check did not work.
Use the more compatible `method_defined?` method.
  • Loading branch information
Odaeus committed Jan 1, 2013
1 parent 933799d commit ab29418
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/ruport/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,16 @@ def stage(*stage_list)
# # other details omitted
# end
def required_option(*opts)
self.required_options ||= []
opts.each do |opt|
self.required_options << opt
(self.required_options ||= []).concat(opts)

o = opt
unless instance_methods(false).include?(o.to_s)
define_method(o) { options.send(o.to_s) }
opts.each do |opt|
unless method_defined?(opt)
define_method(opt) { options.send(opt) }
end
setter = "#{opt}="
unless method_defined?(setter)
define_method(setter) {|t| options.send(setter, t) }
end
opt = "#{opt}="
define_method(opt) {|t| options.send(opt, t) }
end
end

Expand Down

0 comments on commit ab29418

Please sign in to comment.