What does .call
do in Ruby, and how is it used?
I came across this method where .call
is used at the end:
def allow?(controller, action, resource = nil)
allowed = @allow_all || @allowed_actions[[controller.to_s, action.to_s]]
allowed && (allowed == true || resource && allowed.call(resource))
end
However, the documentation doesn’t clearly explain when or how to use .call
. Can someone clarify its purpose and provide examples of call Ruby usage?