Sha256: 4c09ca99870c36ba62741ff5eff96bca62b4a46334b23360c8d354b4be44ecba

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module DynamicMenu
  class Base
    
    def initialize(parent)
      @parent ||= parent
      load_instance_vars
      @menuLinks = AdvancedArray.new
      build_menu
    end
    
    def get_menu_links
      @menuLinks || AdvancedArray.new
    end
    
    def method_missing(method, *args)
      super unless @parent.methods.index method
      @parent.send(method, *args)
    end
    
    def inherit_from menu_name
      #@menuLinks ||= AdvancedHash::AdvancedHash.new
      file = Rails.root.to_s+"/app/menus/#{params[:controller]}/#{menu_name}.rb"
      load file
      links_obj = "#{menu_name}_menu".camelize.classify.constantize.new(@parent)
      @menuLinks.concat(links_obj.get_menu_links)
    end
    
    def load_instance_vars
      @parent.instance_variables.each do |var|
        instance_variable_set(var.intern,@parent.instance_variable_get(var.intern))
      end
    end
    
    def menu_instance
      @menuLinks ||= AdvancedArray.new
    end
    
    def add *args
      args.each do |arg|
        @menuLinks << arg
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dynamic_menu-3.0.2 lib/dynamic_menu/base.rb