lib/jets/controller/base.rb in jets-1.9.32 vs lib/jets/controller/base.rb in jets-2.0.0
- old
+ new
@@ -8,10 +8,12 @@
include Cookies
include Layout
include Params
include Rendering
include ActiveSupport::Rescuable
+ include Jets::Router::Helpers
+ include ForgeryProtection
delegate :headers, to: :request
delegate :set_header, to: :response
attr_reader :request, :response
attr_accessor :session
@@ -74,9 +76,23 @@
def json_dump(data)
JSON.dump(data)
rescue Encoding::UndefinedConversionError
data['body'] = '[BINARY]'
JSON.dump(data)
+ end
+
+ def controller_paths
+ paths = []
+ klass = self.class
+ while klass != Jets::Controller::Base
+ paths << klass.controller_path
+ klass = klass.superclass
+ end
+ paths
+ end
+
+ def self.controller_path
+ name.sub(/Controller$/, "".freeze).underscore
end
def self.process(event, context={}, meth)
controller = new(event, context, meth)
# Using send because process! is private method in Jets::RackController so