Module: Lennarb::Helpers
- Defined in:
- lib/lennarb/helpers.rb
Overview
Simple helpers module for Lennarb applications. Provides helper methods to be used in routes and hooks.
Class Attribute Summary collapse
-
.app_helpers ⇒ Object
readonly
Get the app helpers map.
Class Method Summary collapse
-
.define(app_class, mod_or_block = nil, &block) ⇒ Module
Define helpers for an app class.
-
.for(app_class) ⇒ Module
Get helpers module for an app class.
Class Attribute Details
.app_helpers ⇒ Object (readonly)
Get the app helpers map
10 11 12 |
# File 'lib/lennarb/helpers.rb', line 10 def app_helpers @app_helpers end |
Class Method Details
.define(app_class, mod_or_block = nil, &block) ⇒ Module
Define helpers for an app class
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lennarb/helpers.rb', line 25 def define(app_class, mod_or_block = nil, &block) mod = self.for(app_class) case mod_or_block when Module mod.include(mod_or_block) when Proc mod.module_eval(&mod_or_block) end mod.module_eval(&block) if block_given? mod end |
.for(app_class) ⇒ Module
Get helpers module for an app class
16 17 18 |
# File 'lib/lennarb/helpers.rb', line 16 def for(app_class) app_helpers[app_class] ||= Module.new end |