lundi 13 mai 2019

How to get class instance variable into module

I am unable to overwrite the module variable by class instance variable.

module Main
 class Traks
   @@endpoint ='/trakings'
   class << self
     include ViewTrait
   end
 end 

end

My Trait Module

module Main
 module ViewTrait
      def view(id:, options: "")
        Response::new("#{@@endpoint}/#{id}#{options}").resource(id: id).get
      end
    end
end

in ViewTrait I cannot access @@endponint which I have already defined in my Traks class. anyone can let me what I went wrong.

Aucun commentaire:

Enregistrer un commentaire