Sha256: 93e8d2675da8df8ab02721ff6be5cb2523a418da465230166633bf4867f86b7c

Contents?: true

Size: 542 Bytes

Versions: 3

Compression:

Stored size: 542 Bytes

Contents

module Crystal
  class DefaultRouter
    inject :logger => :logger
    
    def encode klass, method, params
      path = "/#{klass.name.underscore}/#{method}"
      return path, params
    end
    
    def decode path, params
      parts = path[1..-1].split '/'
      if parts.size >= 2
        method = parts.pop        
        
        class_path = parts.join('/')
        class_name = class_path.camelize
        klass = class_name.constantize
                        
        return klass, method, params
      end
    end    
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
crystal-0.0.13 lib/crystal/router/default_router.rb
crystal-0.0.12 lib/crystal/router/default_router.rb
crystal_ext-0.0.11 lib/crystal/router/default_router.rb