1

Found this source code on GitHub:

def objects_from_response(klass, request_method, path, options={})
  response = send(request_method.to_sym, path, options)[:body]
  objects_from_array(klass, response)
end

For this specific line:

response = send(request_method.to_sym, path, options)[:body]

What is that [:body] syntax after the method?

2
  • 1
    Btw, using public_send instead of send is much better if you only want dynamic method calling, not visibility bypassing. Commented Nov 19, 2013 at 3:49
  • In case it's not obvious, your question applies equally to response = my_method(path, options)[:body]. Commented Nov 19, 2013 at 4:53

1 Answer 1

3

send(request_method.to_sym, path, options) returns an object support method [], for example a Hash, then call [:body] on it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.