Sha256: 0335e3573a4be90c2b318792bcf41182eacb6b7bc013125c8a69a2373a7b068e

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 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".classify.constantize.new(@parent)
      @menuLinks << 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.0.rc3 lib/dynamic_menu/base.rb