class JsFromRoutes::Route
Internal: A presenter for an individual Rails action.
Public Class Methods
new(route, mappings = {})
click to toggle source
# File lib/js_from_routes/generator.rb, line 56 def initialize(route, mappings = {}) @route, @mappings = route, mappings end
Public Instance Methods
export()
click to toggle source
Public: The `export` setting specified for the action.
# File lib/js_from_routes/generator.rb, line 61 def export @route.defaults[:export] end
helper()
click to toggle source
Public: The name of the JS helper for the action. Example: 'destroyAll'
# File lib/js_from_routes/generator.rb, line 76 def helper action = @route.requirements.fetch(:action).camelize(:lower) @mappings.fetch(action, action) end
inspect()
click to toggle source
Internal: Useful as a cache key for the route, and for debugging purposes.
# File lib/js_from_routes/generator.rb, line 82 def inspect "#{verb} #{helper} #{path}" end
path()
click to toggle source
Public: The path for the action. Example: '/users/:id/edit'
# File lib/js_from_routes/generator.rb, line 71 def path @route.path.spec.to_s.chomp("(.:format)") end
verb()
click to toggle source
Public: The HTTP verb for the action. Example: 'patch'
# File lib/js_from_routes/generator.rb, line 66 def verb @route.verb.downcase end