Module: Hanami::Controller
- Includes:
- Utils::ClassAttribute
- Defined in:
- lib/hanami/controller.rb,
lib/hanami/controller/error.rb,
lib/hanami/controller/version.rb,
lib/hanami/action/exposable/guard.rb,
lib/hanami/controller/configuration.rb
Overview
A set of logically grouped actions
Defined Under Namespace
Classes: Configuration, Error, IllegalExposureError, MissingSessionError, UnknownFormatError
Constant Summary collapse
- VERSION =
Defines the version
'1.3.3'.freeze
Class Method Summary collapse
-
.configure(&blk) ⇒ Object
Configure the framework.
-
.dupe ⇒ Module
private
Duplicate Hanami::Controller in order to create a new separated instance of the framework.
-
.duplicate(mod, controllers = 'Controllers', &blk) ⇒ Module
Duplicate the framework and generate modules for the target application.
-
.load! ⇒ void
Framework loading entry point.
Class Method Details
.configure(&blk) ⇒ Object
Configure the framework. It yields the given block in the context of the configuration
90 91 92 |
# File 'lib/hanami/controller.rb', line 90 def self.configure(&blk) configuration.instance_eval(&blk) end |
.dupe ⇒ Module
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Duplicate Hanami::Controller in order to create a new separated instance of the framework.
The new instance of the framework will be completely decoupled from the original. It will inherit the configuration, but all the changes that happen after the duplication, won’t be reflected on the other copies.
139 140 141 142 143 |
# File 'lib/hanami/controller.rb', line 139 def self.dupe dup.tap do |duplicated| duplicated.configuration = configuration.duplicate end end |
.duplicate(mod, controllers = 'Controllers', &blk) ⇒ Module
Duplicate the framework and generate modules for the target application
module MyApp::Controllers::Dashboard
include MyApp::Controller
action 'Index' do # this will inject MyApp::Action
def call(params)
# ...
end
end
end
251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/hanami/controller.rb', line 251 def self.duplicate(mod, controllers = 'Controllers', &blk) dupe.tap do |duplicated| mod.module_eval %{ module #{ controllers }; end } if controllers mod.module_eval %{ Action = Hanami::Action.dup } duplicated.module_eval %{ configure do action_module #{ mod }::Action end } duplicated.configure(&blk) if block_given? end end |
.load! ⇒ void
This method returns an undefined value.
Framework loading entry point
271 272 273 |
# File 'lib/hanami/controller.rb', line 271 def self.load! configuration.load! end |