Class: Wurk::Web::Extension::App

Inherits:
Object
  • Object
show all
Defined in:
lib/wurk/web/extension.rb

Overview

Captures the routes + helpers an extension declares in ‘registered`. Quacks like the slice of `Sidekiq::Web::Application` extensions touch.

Constant Summary collapse

HTTP_METHODS =
%i[get post put patch delete head].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApp

Returns a new instance of App.



31
32
33
34
35
# File 'lib/wurk/web/extension.rb', line 31

def initialize
  @routes = [] # [[method_string, Route, block], …]
  @helper_modules = []
  @helper_blocks = []
end

Instance Attribute Details

#helper_blocksObject (readonly)

Returns the value of attribute helper_blocks.



27
28
29
# File 'lib/wurk/web/extension.rb', line 27

def helper_blocks
  @helper_blocks
end

#helper_modulesObject (readonly)

Returns the value of attribute helper_modules.



27
28
29
# File 'lib/wurk/web/extension.rb', line 27

def helper_modules
  @helper_modules
end

#routesObject (readonly)

Returns the value of attribute routes.



27
28
29
# File 'lib/wurk/web/extension.rb', line 27

def routes
  @routes
end

Instance Method Details

#configureObject



53
# File 'lib/wurk/web/extension.rb', line 53

def configure(*) = (yield self if block_given?)

#helpers(*mods, &block) ⇒ Object

Sidekiq extensions add helpers via ‘app.helpers(Mod)` and/or a block.



44
45
46
47
48
# File 'lib/wurk/web/extension.rb', line 44

def helpers(*mods, &block)
  @helper_modules.concat(mods)
  @helper_blocks << block if block
  self
end

#setObject

Sinatra settings calls some extensions make — accepted no-op.



51
# File 'lib/wurk/web/extension.rb', line 51

def set(*); end

#settingsObject



52
# File 'lib/wurk/web/extension.rb', line 52

def settings = self