Module: Jets::Router::Util
- Included in:
- MethodCreator, MethodCreator::Code, Route, Scope
- Defined in:
- lib/jets/router/util.rb
Instance Method Summary collapse
- #get_controller_action(options) ⇒ Object
- #handle_on!(options) ⇒ Object
-
#join(*items) ⇒ Object
used in MethodCreator logic.
- #underscore(str) ⇒ Object
Instance Method Details
#get_controller_action(options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jets/router/util.rb', line 14 def get_controller_action() if .key?(:controller) && .key?(:action) [[:controller], [:action]] elsif .key?(:controller) && .key?(:to) action = [:to].split('#').last [[:controller], action] elsif .key?(:on) handle_on!() else [:to].split('#') # controller, action end end |
#handle_on!(options) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jets/router/util.rb', line 27 def handle_on!() controller = @scope.[:prefix].to_s to = "#{controller}##{[:path]}" [:to] = to as = @options[:on] == :member ? controller.singularize : controller as = "#{@options[:path]}_#{as}" [:as] = as to.split('#') end |
#join(*items) ⇒ Object
used in MethodCreator logic
4 5 6 7 |
# File 'lib/jets/router/util.rb', line 4 def join(*items) list = items.compact.join('_') underscore(list) end |
#underscore(str) ⇒ Object
9 10 11 12 |
# File 'lib/jets/router/util.rb', line 9 def underscore(str) return unless str str.to_s.gsub(/[^a-zA-Z0-9]/,'_') end |