Hey all,
I have a question about this line of code:
within "#main-menu" do
find("h6", :text => menu).click if menu
click_link link
end
def within(selector, &blk)
new_blk = proc do
begin
scope_selectors.push(selector)
blk.call
ensure
scope_selectors.pop
end
end
super(selector.strip, &new_blk)
end
First, when within is called, it obviously passes the string
"#main-menu", but does it also pass the block (the content between do
and end) as the second argument? The reason why I ask is because notice
within requires a second argument: &blk.
Second, we create a proc to convert a code block into an object and
store that object into new_blk local variable. Then we call the object
in the super argument list, which adds the selector (e.g. "#main-menu")
into the scope_selectors array. Then it seems like we call the initial
code block (blk.call) adjacent to within(). But the blk code block has
not been
converted to a proc, so how is it possible to have a callable block
then?
Finally, super is only called on a parent class with a method of the
same name correct? Because in this case, within() is the only method in
entire application. super has another purpose?
Thanks for response.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.