Sha256: 1f8835373c0352755afbc76133306594faff6123cf85931dc55133f706ac93ad

Contents?: true

Size: 1.3 KB

Versions: 24

Compression:

Stored size: 1.3 KB

Contents

module Rad::Router::AbstractRouter
  
  class Meta < Hash
    def get_class
      @klass ||= self[:class_name].constantize
    end
  end

  protected
    def parse_url_root options
      url_root = options[:url_root]
      url_root.must =~ /^\/.*/ if url_root
      url_root = nil if url_root == '/'
      url_root
    end
  
    def parse_prefix options      
      prefix = Array(options[:prefix])
      prefix.empty? ? nil : prefix
    end

    def encode_prefix_params! path, params, prefix
      parts = []
      prefix.each do |name|            
        value = params.delete(name) || (rad.workspace? && rad.workspace.params[name])
        raise "not provided :#{name} prefix!" unless value
        parts << value.to_param.to_s.url_escape
      end
      "/#{parts.join('/')}#{path}"
    end
  
    # def encode_url_root! path, meta
    #   if url_root = meta[:url_root]
    #     "#{url_root}#{path}" 
    #   else
    #     path
    #   end
    # end
  
    def decode_prefix_params! parts, params, prefix
      prefix.each do |name|            
        params[name] = parts.shift || raise("not provided :#{name} prefix!")
      end
    end
  
    def decode_url_root! parts, url_root
      raise 'not implemented'
      # raise "invalid :url_root!" if meta[:url_root] and meta[:url_root] != "/#{parts.join('/')}"
    end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rad_core-0.2.6 lib/rad/router/_abstract_router.rb
rad_core-0.2.5 lib/rad/router/_abstract_router.rb
rad_core-0.2.4 lib/rad/router/_abstract_router.rb
rad_core-0.2.3 lib/rad/router/_abstract_router.rb
rad_core-0.2.2 lib/rad/router/_abstract_router.rb
rad_core-0.2.1 lib/rad/router/_abstract_router.rb
rad_core-0.2.0 lib/rad/router/_abstract_router.rb
rad_core-0.0.30 lib/rad/router/_abstract_router.rb
rad_core-0.0.29 lib/rad/router/_abstract_router.rb
rad_core-0.0.28 lib/rad/router/_abstract_router.rb
rad_core-0.0.27 lib/rad/router/_abstract_router.rb
rad_core-0.0.26 lib/rad/router/_abstract_router.rb
rad_core-0.0.25 lib/rad/router/_abstract_router.rb
rad_core-0.0.24 lib/rad/router/_abstract_router.rb
rad_core-0.0.23 lib/rad/router/_abstract_router.rb
rad_core-0.0.22 lib/rad/router/_abstract_router.rb
rad_core-0.0.21 lib/rad/router/_abstract_router.rb
rad_core-0.0.20 lib/rad/router/_abstract_router.rb
rad_core-0.0.19 lib/rad/router/_abstract_router.rb
rad_core-0.0.18 lib/rad/router/_abstract_router.rb