Skip to content

Instantly share code, notes, and snippets.

@deivinsontejeda
Created August 14, 2013 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deivinsontejeda/6235765 to your computer and use it in GitHub Desktop.
Save deivinsontejeda/6235765 to your computer and use it in GitHub Desktop.
class TestDSL < Regexp
def initialize(&block)
instance_eval &block
super('/some_regex/')
end
def some_method(value)
puts "Output: #{value}"
end
end
# Using previous code
TestDSL.new { some_method 'Hi!' }
# raise the follow error
ArgumentError: block not supplied
from org/jruby/RubyBasicObject.java:1709:in `instance_eval'
from (irb):10:in `initialize'
from org/jruby/RubyRegexp.java:729:in `new'
from (irb):17:in `evaluate'
from org/jruby/RubyKernel.java:1066:in `eval'
from org/jruby/RubyKernel.java:1409:in `loop'
from org/jruby/RubyKernel.java:1174:in `catch'
from org/jruby/RubyKernel.java:1174:in `catch'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment