Class: Jets::Router::Resources::Filter

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/router/resources/filter.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Jets::Router::Resources::Base

Instance Method Details

#yes?(action) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
13
# File 'lib/jets/router/resources/filter.rb', line 3

def yes?(action)
  return true unless @options[:only] || @options[:except]

  if @options[:only]
    only = [@options[:only]].flatten.map(&:to_s)
    only.include?(action.to_s)
  else # except
    except = [@options[:except]].flatten.map(&:to_s)
    !except.include?(action.to_s)
  end
end