Module: Lotus::View
- Includes:
- Utils::ClassAttribute
- Defined in:
- lib/lotus/view.rb,
lib/lotus/view/dsl.rb,
lib/lotus/view/version.rb,
lib/lotus/view/template.rb,
lib/lotus/view/rendering.rb,
lib/lotus/view/inheritable.rb,
lib/lotus/view/configuration.rb,
lib/lotus/view/rendering/scope.rb,
lib/lotus/view/rendering/partial.rb,
lib/lotus/view/rendering/registry.rb,
lib/lotus/view/rendering/template.rb,
lib/lotus/view/rendering/null_layout.rb,
lib/lotus/view/rendering/view_finder.rb,
lib/lotus/view/rendering/layout_scope.rb,
lib/lotus/view/rendering/layout_finder.rb,
lib/lotus/view/rendering/null_template.rb,
lib/lotus/view/rendering/template_name.rb,
lib/lotus/view/rendering/partial_finder.rb,
lib/lotus/view/rendering/layout_registry.rb,
lib/lotus/view/rendering/template_finder.rb,
lib/lotus/view/rendering/templates_finder.rb
Overview
View
Defined Under Namespace
Modules: Dsl, Inheritable, Rendering Classes: Configuration, MissingFormatError, MissingTemplateError, Template
Constant Summary collapse
- VERSION =
Defines the version
'0.2.0'.freeze
Class Method Summary collapse
-
.configure(&blk) ⇒ Object
Configure the framework.
-
.dupe ⇒ Module
private
Duplicate Lotus::View in order to create a new separated instance of the framework.
-
.duplicate(mod, views = 'Views', &blk) ⇒ Module
Duplicate the framework and generate modules for the target application.
-
.included(base) ⇒ Object
private
Override Ruby’s hook for modules.
-
.load! ⇒ Object
private
Load the framework.
-
.unload! ⇒ Object
private
Unload the framework.
Class Method Details
.configure(&blk) ⇒ Object
Configure the framework. It yields the given block in the context of the configuration
70 71 72 |
# File 'lib/lotus/view.rb', line 70 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::View 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.
119 120 121 122 123 |
# File 'lib/lotus/view.rb', line 119 def self.dupe dup.tap do |duplicated| duplicated.configuration = configuration.duplicate end end |
.duplicate(mod, views = 'Views', &blk) ⇒ Module
Duplicate the framework and generate modules for the target application
@since 0.2.0
module MyApp::Views::Dashboard
class Index
include MyApp::View
end
end
227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/lotus/view.rb', line 227 def self.duplicate(mod, views = 'Views', &blk) dupe.tap do |duplicated| mod.module_eval %{ module #{ views }; end } if views mod.module_eval %{ Layout = Lotus::Layout.dup } duplicated.configure do namespace [mod, views].compact.join '::' end duplicated.configure(&blk) if block_given? end end |
.included(base) ⇒ Object
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.
Override Ruby’s hook for modules. It includes basic Lotus::View modules to the given Class. It sets a copy of the framework configuration
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/lotus/view.rb', line 261 def self.included(base) conf = self.configuration conf.add_view(base) base.class_eval do extend Inheritable.dup extend Dsl.dup extend Rendering.dup include Utils::ClassAttribute class_attribute :configuration self.configuration = conf.duplicate end end |
.load! ⇒ Object
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.
Load the framework
281 282 283 |
# File 'lib/lotus/view.rb', line 281 def self.load! configuration.load! end |
.unload! ⇒ Object
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.
Unload the framework
289 290 291 |
# File 'lib/lotus/view.rb', line 289 def self.unload! configuration.unload! end |