lib/class_action.rb in class-action-1.2.0 vs lib/class_action.rb in class-action-1.2.1

- old
+ new

@@ -40,9 +40,25 @@ inject_class_action_mimes action.to_s, action_class end end + # Delegates the given method to the current class action. + def class_action_delegate(*methods) + file, line = caller.first.split(':', 2) + line = line.to_i + + methods.each do |method| + definition = (method =~ /[^\]]=$/) ? 'arg' : '*args, &block' + + module_eval(<<-RUBY, file, line) + def #{method}(#{definition}) + class_action.send :#{method}, #{definition} + end + RUBY + end + end + private # Injects the mimes (formats) that the action responds to into the controller # mimes_for_respond_to hash. def inject_class_action_mimes(action, klass) \ No newline at end of file