Module: Lotus::Controller
- Includes:
- Utils::ClassAttribute
- Defined in:
- lib/lotus/controller.rb,
lib/lotus/controller/version.rb,
lib/lotus/controller/configuration.rb
Overview
A set of logically grouped actions
Defined Under Namespace
Classes: Configuration, UnknownFormatError
Constant Summary collapse
- VERSION =
Defines the version
'0.4.3'.freeze
Class Method Summary collapse
-
.configure(&blk) ⇒ Object
Configure the framework.
-
.dupe ⇒ Module
private
Duplicate Lotus::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
68 69 70 |
# File 'lib/lotus/controller.rb', line 68 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 Lotus::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.
117 118 119 120 121 |
# File 'lib/lotus/controller.rb', line 117 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
@since 0.2.0
module MyApp::Controllers::Dashboard
include MyApp::Controller
action 'Index' do # this will inject MyApp::Action
def call(params)
# ...
end
end
end
229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/lotus/controller.rb', line 229 def self.duplicate(mod, controllers = 'Controllers', &blk) dupe.tap do |duplicated| mod.module_eval %{ module #{ controllers }; end } if controllers mod.module_eval %{ Action = Lotus::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
249 250 251 |
# File 'lib/lotus/controller.rb', line 249 def self.load! configuration.load! end |