module Utopia::Controller::Actions::ClassMethods
Exposed to the controller class.
Public Class Methods
extended(klass)
click to toggle source
# File lib/utopia/controller/actions.rb, line 128 def self.extended(klass) klass.instance_eval do @actions = nil @otherwise = nil end end
Public Instance Methods
actions()
click to toggle source
# File lib/utopia/controller/actions.rb, line 135 def actions @actions ||= Action.new end
dispatch(controller, request, path)
click to toggle source
# File lib/utopia/controller/actions.rb, line 151 def dispatch(controller, request, path) if @actions matched = @actions.apply(path.components) do |action| controller.instance_exec(request, path, &action.callback) end end if @otherwise and !matched controller.instance_exec(request, path, &@otherwise) end end
on(first, *path, **options, &block)
click to toggle source
# File lib/utopia/controller/actions.rb, line 139 def on(first, *path, **options, &block) if first.is_a? Symbol first = ['**', first.to_s] end actions.define(Path.split(first) + path, **options, &block) end
otherwise(&block)
click to toggle source
# File lib/utopia/controller/actions.rb, line 147 def otherwise(&block) @otherwise = block end