Question

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

How can I access api_client method ?

I'm following this but didn't access it.

Search::SocialMention.new(query).api_client

What is the correct way to access private method ?

Thanks

Was it helpful?

Solution

You could do external access to private methods via the Object#send method:

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

But since you want to access it outside, why do you put it as private at first?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top