Sha256: 05efdc3f4b038dc2cd98faf054a9fc6d7ca92e8fcc915e9986aff3d0b3cf54c0

Contents?: true

Size: 1.11 KB

Versions: 24

Compression:

Stored size: 1.11 KB

Contents

module Rad::Router::CoreRoutingHelper
  inject router: :router

  delegate :url_for, :url_for_path, :persist_params, :persist_params?, :dont_persist_params, to: :router 

  def default_path options = {}
    url_for_path rad.router.default_path, options.merge(url_root: false)
  end

  def return_to_path options = {}
    dont_persist_params do 
      path = params[:_return_to] || workspace.request.session['return_to'] || rad.router.default_path
      url_for_path path, options.merge(url_root: false)
    end
  end

  def parse_routing_arguments *args
    params = args.extract_options!
    raise "invalid usage!" unless args.size <= 1
    if args.size == 1
      raise "duplicate :id pameter!" if params.include?(:id) or params.include?('id')
      params[:id] = args.first.to_param
    end
    params      
  end

  protected
    def method_missing m, *args, &block
      m = m.to_s
      if m =~ /path$/
        params = parse_routing_arguments(*args)
        klass, method = router.encode_method m, params.include?(:id)
      
        url_for klass, method, params
      else
        super m.to_sym, *args, &block
      end
    end
end

Version data entries

24 entries across 24 versions & 1 rubygems

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