2

Why does the following code result in the error 'undefined local variable or method `foo_client' for Foo::People:Class'

class Foo::People

  class << self
    def get_account_balance(account_num)
      foo_client.request :get_account_balance, :body => {"AccountNum" => account_num}
    end
  end

  def foo_client
    @@client ||= Savon::Client.new do|wsdl, http|
      wsdl.document = PEOPLE_SERVICE_ENDPOINT[:uri] + "?WSDL"
      wsdl.endpoint = PEOPLE_SERVICE_ENDPOINT[:uri]
    end
  end

end

1 Answer 1

7

def get_account_balance is inside the class << self block, so it's a class method. def foo_client is not, so it's an instance method. So you can't call foo_client from get_account_balance because you're not calling it on an instance of People.

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.