Class: InertiaRails::ActionFilter
- Inherits:
-
Object
- Object
- InertiaRails::ActionFilter
- Defined in:
- lib/inertia_rails/action_filter.rb
Instance Method Summary collapse
-
#initialize(conditional_key, actions) ⇒ ActionFilter
constructor
A new instance of ActionFilter.
- #match?(controller) ⇒ Boolean
Constructor Details
#initialize(conditional_key, actions) ⇒ ActionFilter
Returns a new instance of ActionFilter.
7 8 9 10 |
# File 'lib/inertia_rails/action_filter.rb', line 7 def initialize(conditional_key, actions) @conditional_key = conditional_key @actions = Array(actions).map(&:to_s).to_set end |
Instance Method Details
#match?(controller) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/inertia_rails/action_filter.rb', line 12 def match?(controller) missing_action = @actions.find { |action| !controller.available_action?(action) } if missing_action = <<~MSG The #{missing_action} action could not be found for the :inertia_share callback on #{controller.class.name}, but it is listed in the controller's #{@conditional_key.inspect} option. MSG raise AbstractController::ActionNotFound.new(, controller, missing_action) end @actions.include?(controller.action_name) end |