olivernn / poirot

mustaches in your rails
http://olivernn.github.com/poirot
108 stars 21 forks source link

Poirot::View method_missing glitch #7

Open oelmekki opened 13 years ago

oelmekki commented 13 years ago

Hello,

I'm working on a copy of poirot that I have adapted for my needs, in the context of a 3.1 mountable engine, so I'm not sure if the problem exists on your version, but just in case you hit it :

I had to change the method_missing method in Poirot::View : https://github.com/olivernn/poirot/blob/master/lib/poirot/view.rb#L18

When I was calling "new_whatever_path" in a subclass, it returned me nil. Problem is, instance_var was tested to see if it was defined, which I don't understand how it can not be, since it's defined in the previous line.

So, I changed the method to :

def method_missing(method_name, *args, &block)
  if instance_variable_defined?( "@#{method_name}" ) && args.empty?
    instance_variable_get("@#{method_name}")
  else
    view_context.send(method_name,*args, &block)
  end
end