Skip to content

Confusing method_missing errors #2

@coreyward

Description

@coreyward

Decorum can be hard to develop with because it consumes method_missing errors from further down the call stack. For example, this happens to me a lot:

class House
  include Decorum::Decorations
  # note: no `is_couch?` method
end

class InteriorDecorator < Decorum::Decorator
  def couch
    object.furniture.detect { |f| f.is_couch? }
  end
end

h = House.new
h.decorate(InteriorDecorator)

# Expected:                                     ⇣
h.couch #=> NoMethodError: undefined method `is_couch?` for #<House:0x007fe054553750>

# Actual:
h.couch #=> NoMethodError: undefined method `couch' for #<House:0x007fe054553750>

Dropping a byebug call in couch results in halting execution at the expected point, and causing a method_missing error during the debugging session actually breaks out of it.

Any insight as to how this could be avoided?

Edit: I know, I'm a bad person for using puns in example code and making concepts harder to grok. Sorry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions