Sha256: 804eb37c4e9c7136316ff1b50291424d77598ec8ec06f5044f0f30f09c7e0b29

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module RubyApp
  
  module Elements
    
    module Navigation
      require 'rubyapp/element'

      class PageMenu < RubyApp::Element
    
        class NavigatedEvent < RubyApp::Element::Event
      
          attr_reader :page
      
          def initialize(data)
            super(data)
            @page = eval(data['page'])
          end
    
          def to_hash
            super.merge('page' => @page)
          end

        end
    
        template_path(__FILE__)

        attr_reader :pages

        def initialize
          super
          @pages = []
        end
        
        def current_page
          RubyApp::Session.current.pages.last.class
        end
    
        protected
    
          def on_event(event)
            super(event)
            on_navigated(event) if event.is_a?(RubyApp::Elements::Navigation::PageMenu::NavigatedEvent)
          end
      
          def on_navigated(event)
            RubyApp::Session.current.pages.pop
            RubyApp::Session.current.pages << event.page.new
            event.refresh
          end
          
      end

    end
  
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
_rubyapp-0.0.3 lib/rubyapp/elements/navigation/page_menu.rb