Module: Decco
- Defined in:
- lib/decco.rb,
lib/decco/helpers.rb,
lib/decco/railtie.rb,
lib/decco/version.rb
Defined Under Namespace
Modules: Helpers Classes: DecoratorNotFound, Railtie
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
-
.builder(object, decorator, view) ⇒ Mixed
Get decorator.
-
.decorate(object, decorator = nil, view = nil) ⇒ Mixed
Decorate an object.
Class Method Details
.builder(object, decorator, view) ⇒ Mixed
Get decorator
26 27 28 29 30 |
# File 'lib/decco.rb', line 26 def self.builder(object, decorator, view) decorator || begin [object.class.to_s, 'Decorator'].join('').classify.constantize end.new(object, view) end |
.decorate(object, decorator = nil, view = nil) ⇒ Mixed
Decorate an object
15 16 17 18 19 20 |
# File 'lib/decco.rb', line 15 def self.decorate(object, decorator = nil, view = nil) @_d ||= {} @_d[object] ||= builder(object, decorator, view) rescue NameError raise DecoratorNotFound end |