Using methods from hash branches #394
Replies: 3 comments 1 reply
|
That approach should work. Try building a minimal app with the code you are showing to see that it works. If you have problems with a minimal app with just that code, please post the minimal app and I'll take a look. |
|
A minimal app helped me determine that it was a scope issue. I'm definitely going to keep this minimal app around for helping verify these kinds of questions before asking here in the future. |
|
Actually, on further testing, it seems to only go in one direction, i.e. if # app.rb
require 'roda'
class App < Roda
plugin :autoload_hash_branches
autoload_hash_branch_dir('./routes')
route do |r|
r.hash_branches ''
r.is 'hello' do
say_hello
end
end
end# routes/test.rb
class App
hash_branch('test') do |r|
# /test branch handling
r.is 'hello' do
say_hello
end
end
def say_hello
'hello'
end
end |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Is one supposed to redefine methods one wishes to use in each hash branch file instead of being able to use methods already defined in the main class file? Or am I doing something wrong?
All reactions