ruby - Rails: Override and also use existing gem module method -


i've gem helper module. eg

gem module

module hotel  module menuitem   def menu(session)     x = default_food_menu[session]   end    def print_menu(menu)     #printing menu   end end 

custom class

module sizzsuzzhotel  module menuitem    include hotel::menuitem   def menu(session)     # want use default menu item , specific menu related hotel! .    end end  module sizzsuzzhotel  class order   include menuitem     def order(session)        menu_item = menu(session)          print(menu_item)     end     end end 

here want override menu , want use existing print_menu! how can achieve this? use gem module method , add few more stuffs it?

if include menuitem module, both methods available, can redefine 1 of them.

include menuitem  def menu(session)   ... here write custom menu method behaviour end  def order(session)   menu_item = menu(session) # => above menu method called   print(menu_item) # => print method menuitem module called end 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -