lib/much-rails/action/controller.rb in much-rails-0.1.1 vs lib/much-rails/action/controller.rb in much-rails-0.1.2
- old
+ new
@@ -7,10 +7,12 @@
module MuchRails::Action; end
# MuchRails::Action::Controller defines the behaviors for controllers processing
# MuchRails::Actions.
module MuchRails::Action::Controller
+ DEFAULT_ACTION_CLASS_FORMAT = :any
+
include MuchRails::Mixin
mixin_included do
attr_reader :much_rails_action_class
@@ -24,11 +26,11 @@
mixin_instance_methods do
define_method(
MuchRails::Action::Router::CONTROLLER_CALL_ACTION_METHOD_NAME,
) do
respond_to do |format|
- format.public_send(much_rails_action_class.format) do
+ format.public_send(much_rails_action_class_format) do
result =
much_rails_action_class.call(
params: much_rails_action_params,
current_user: current_user,
request: request,
@@ -48,9 +50,13 @@
end
end
def much_rails_action_class_name
"::#{params[MuchRails::Action::Router::ACTION_CLASS_PARAM_NAME]}"
+ end
+
+ def much_rails_action_class_format
+ much_rails_action_class.format || DEFAULT_ACTION_CLASS_FORMAT
end
def much_rails_action_params
# If a `params_root` value is specified, pull the params from that key and
# merge them into the base params.