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
Post a Comment