Sha256: d9be33d3b25c410795ac942a46e7c935aca1eb05ae480c72f6e40159fec71c12

Contents?: true

Size: 1.4 KB

Versions: 5

Compression:

Stored size: 1.4 KB

Contents

class Usher
  module Interface
    class Rails22Interface
      
      class Mapper #:doc:
        def initialize(set) #:nodoc:
          @set = set
        end

        def connect(path, options = nil)
          @set.add_route(path, options)
        end

        def root(options = {})
          if options.is_a?(Symbol)
            if source_route = @set.named_routes[options]
              options = source_route.conditions.blank? ? 
                source_route.options.merge({ :conditions => source_route.conditions }) : source_route.options
            end
          end
          named_route(:root, '/', options)
        end

        def named_route(name, path, options = nil)
          @set.add_named_route(name, path, options)
        end

        def namespace(name, options = {}, &block)
          if options[:namespace]
            with_options({:path_prefix => "#{options.delete(:path_prefix)}/#{name}", :name_prefix => "#{options.delete(:name_prefix)}#{name}_", :namespace => "#{options.delete(:namespace)}#{name}/" }.merge(options), &block)
          else
            with_options({:path_prefix => name, :name_prefix => "#{name}_", :namespace => "#{name}/" }.merge(options), &block)
          end
        end

        def method_missing(route_name, *args, &proc) #:nodoc:
          super unless args.length >= 1 && proc.nil?
          @set.add_named_route(route_name, *args)
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
joshbuddy-usher-0.5.7 lib/usher/interface/rails2_2_interface/mapper.rb
usher-0.5.11 lib/usher/interface/rails2_2_interface/mapper.rb
usher-0.5.10 lib/usher/interface/rails2_2_interface/mapper.rb
usher-0.5.8 lib/usher/interface/rails2_2_interface/mapper.rb
usher-0.5.7 lib/usher/interface/rails2_2_interface/mapper.rb