How to access private class methods in Rails -


i have class initialization.

i have method send_mail class method

def self.send_mail   = user_stats end 

user_stats private method , when try call method, throws error

class << self    private    def user_stats     true   end  end 

when tried accessing user_stats ,

 undefined method 'user_stats' initialization 

also tried

class << self  def self.send_mail   = user_stats end    private    def user_stats     true   end  end 

both of approaches correct, in latter shouldn't use self, cause define method in initialization's eigenclass:

class initialization   class << self     def send_mail       = user_stats     end     private     def user_stats       true     end   end end initialization.send_mail # => true 

your first approach works me:

class initialization   def self.send_mail     = user_stats   end   class << self     private     def user_stats       true     end   end end initialization.send_mail # => true 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -