2014-04-23 1 views
0

base.rb어떻게 개인 방법을

module Search 
    class Base 

    attr_accessor :query_model 
    attr_accessor :result 

    def initialize(query_obj) 
     self.query_model = query_obj 
    end 

    def execute   
    end 

    end 
end 

social_mention.rb

module Search 
    class SocialMention < Base 

    def execute 
     self.result = RestClient.get api_client, :params => query_params 
     parse_result 
    end 

    private 

    def api_client 
     'http://socialmention.com/search' 
    end 
end 

가 어떻게 액세스 할 수 있습니다 api_client 방법을 액세스 할 수 있습니까?

다음을 따르지만 접속하지 않았습니다.

Search::SocialMention.new(query).api_client 

개인 방법에 액세스하는 올바른 방법은 무엇입니까?

감사

답변

5

당신은 Object#send 방법을 통해 개인 방법에 대한 외부 액세스를 할 수있는 :

Search::SocialMention.new(query).send(:api_client) 

을하지만 외부 액세스하려는 때문에, 왜 당신이 처음에 비공개로 배치해야합니까?

+0

오, 정말 고마워. –

관련 문제