Permalink
Browse files

refactor of method_missing for ease of reading

  • Loading branch information...
markburns committed Mar 3, 2012
1 parent 051dec8 commit 08718df5c425ca8317a7926d956670caa9eda1ca
Showing with 9 additions and 12 deletions.
  1. +9 −12 lib/draper/base.rb
View
@@ -202,19 +202,16 @@ def respond_to?(method, include_private = false)
end
def method_missing(method, *args, &block)
- if allow?(method)
- begin
- self.class.send :define_method, method do |*args, &block|
- model.send(method, *args, &block)
- end
- self.send(method, *args, &block)
- rescue NoMethodError => no_method_error
- super if no_method_error.name == method
- raise no_method_error
- end
- else
- super
+ super unless allow?(method)
+
+ self.class.send :define_method, method do |*args, &block|
+ model.send(method, *args, &block)
end
+ self.send(method, *args, &block)
+
+ rescue NoMethodError => no_method_error
+ super if no_method_error.name == method
+ raise no_method_error
end
def self.method_missing(method, *args, &block)

0 comments on commit 08718df

Please sign in to comment.