Sha256: 4b775142e3052b83d84a3c09eaa80ee0357c1a5229f61c2128cbcf3b5edd8ca7

Contents?: true

Size: 1006 Bytes

Versions: 87

Compression:

Stored size: 1006 Bytes

Contents

class Jets::Router
  module Util
    # used in MethodCreator logic
    def join(*items)
      list = items.compact.join('_')
      underscore(list)
    end

    def underscore(str)
      return unless str
      str.to_s.gsub(/[^a-zA-Z0-9]/,'_')
    end

    def get_controller_action(options)
      if options.key?(:controller) && options.key?(:action)
        [options[:controller], options[:action]]
      elsif options.key?(:controller) && options.key?(:to)
        action = options[:to].split('#').last
        [options[:controller], action]
      elsif options.key?(:on)
        handle_on!(options)
      else
        options[:to].split('#') # controller, action
      end
    end

    def handle_on!(options)
      controller = @scope.options[:prefix].to_s
      to = "#{controller}##{options[:path]}"
      options[:to] = to

      as = @options[:on] == :member ? controller.singularize : controller
      as = "#{@options[:path]}_#{as}"
      options[:as] = as
      to.split('#')
    end
  end
end

Version data entries

87 entries across 87 versions & 2 rubygems

Version Path
jets-4.0.12 lib/jets/router/util.rb
jets-4.0.11 lib/jets/router/util.rb
jets-4.0.10 lib/jets/router/util.rb
jets-4.0.9 lib/jets/router/util.rb
jets-4.0.8 lib/jets/router/util.rb
jets-4.0.7 lib/jets/router/util.rb
jets-4.0.6 lib/jets/router/util.rb
jets-4.0.5 lib/jets/router/util.rb
jets-4.0.4 lib/jets/router/util.rb
jets-4.0.3 lib/jets/router/util.rb
jets-4.0.2 lib/jets/router/util.rb
jets-4.0.1 lib/jets/router/util.rb
jets-4.0.0 lib/jets/router/util.rb
jets-3.2.2 lib/jets/router/util.rb
jets-3.2.1 lib/jets/router/util.rb
jets.benforeva-3.0.17.pre.mount.pre.fix lib/jets/router/util.rb
jets-3.2.0 lib/jets/router/util.rb
jets-3.1.5 lib/jets/router/util.rb
jets-3.1.4 lib/jets/router/util.rb
jets-3.1.3 lib/jets/router/util.rb