Module: RuboCop::Cop::Isucon::Mixin::SinatraMethods
- Extended by:
- NodePattern::Macros
- Included in:
- Sinatra::DisableLogging, Sinatra::ServeStaticFile
- Defined in:
- lib/rubocop/cop/isucon/mixin/sinatra_methods.rb
Overview
Helper methods for Sinatra
Instance Method Summary collapse
-
#parent_is_sinatra_app?(node) ⇒ Boolean
Whether parent node match to
class AnyClass < Sinatra::Base
node. -
#subclass_of_sinatra_base?(node) ⇒ Boolean
Whether match to
class AnyClass < Sinatra::Base
node. -
#subclass_of_sinatra_base_contains_logging?(node) ⇒ Boolean
Whether match to
class AnyClass < Sinatra::Base
node and contains :logging configuration.
Instance Method Details
#parent_is_sinatra_app?(node) ⇒ Boolean
Whether parent node match to class AnyClass < Sinatra::Base
node
30 31 32 |
# File 'lib/rubocop/cop/isucon/mixin/sinatra_methods.rb', line 30 def parent_is_sinatra_app?(node) node.each_ancestor.any? { |ancestor| subclass_of_sinatra_base?(ancestor) } end |
#subclass_of_sinatra_base?(node) ⇒ Boolean
Whether match to class AnyClass < Sinatra::Base
node
15 16 17 |
# File 'lib/rubocop/cop/isucon/mixin/sinatra_methods.rb', line 15 def_node_matcher :subclass_of_sinatra_base?, <<~PATTERN (class (const nil? _) (const (const nil? :Sinatra) :Base) ...) PATTERN |
#subclass_of_sinatra_base_contains_logging?(node) ⇒ Boolean
Whether match to class AnyClass < Sinatra::Base
node and contains :logging configuration
23 24 25 |
# File 'lib/rubocop/cop/isucon/mixin/sinatra_methods.rb', line 23 def_node_matcher :subclass_of_sinatra_base_contains_logging?, <<~PATTERN (class (const nil? _) (const (const nil? :Sinatra) :Base) ... `(send nil? _ (sym :logging))) PATTERN |