Skip to content

Instantly share code, notes, and snippets.

@gosukiwi
Last active June 21, 2017 18:42
Show Gist options
  • Select an option

  • Save gosukiwi/746845834ce168cc6689de3ee08f5838 to your computer and use it in GitHub Desktop.

Select an option

Save gosukiwi/746845834ce168cc6689de3ee08f5838 to your computer and use it in GitHub Desktop.
class BaseParser
private
# We use some reflection to prettify the parser depedencies. Basically, from
# calling a `foo_parser` method is the same as doing `ParserFactory.build('foo_parser')`.
#
def method_missing(name, *args, &block)
raise ArgumentError.new("Method #{name} does not exist.") unless name.to_s.end_with?('_parser')
ParserFactory.build(name, *args, &block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment