Sha256: 200c882baad556de6b14105abeb91ffd612312bd82f67c27e8d155d4c67cc05d

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

module Lolita
  module Menu
    module Autocomplete
      class LinkSet
        include ::Rails.application.routes.url_helpers

        def initialize(&block)
          @links = []
        end

        def add *args
          unless @file
            @file = Lolita::Menu::Autocomplete::FileBuilder.new("a")
            new_stream = true
          end
          @file.add(*args)
          if new_stream
            finalize_file!
          end
        end

        def create &block
          @file = Lolita::Menu::Autocomplete::FileBuilder.new("w")
          begin
            instance_eval(&block)
          ensure
            finalize_file!
          end
        end

        private

        def finalize_file!
          @file.finalize! 
          @file = nil
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lolita-menu-0.2.2 lib/lolita-menu/autocomplete/link_set.rb
lolita-menu-0.2.1 lib/lolita-menu/autocomplete/link_set.rb