Module: KDecor::ResolveInstance
- Included in:
- DecoratorHash, Helper
- Defined in:
- lib/k_decor/resolve_instance.rb
Overview
Decorator set will hold a set of instantiated decorators with lookup keys
Instance Method Summary collapse
-
#resolve_decorator_instance(decorator) ⇒ Object
Decorator instance will accept a decorator in the form of Class or Instance.
Instance Method Details
#resolve_decorator_instance(decorator) ⇒ Object
Decorator instance will accept a decorator in the form of Class or Instance
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/k_decor/resolve_instance.rb', line 9 def resolve_decorator_instance(decorator) if decorator.is_a?(Class) return decorator.new if decorator.ancestors.include?(KDecor::BaseDecorator) raise KType::Error, 'Class type is not a KDecor::BaseDecorator' end raise KType::Error, 'Class instance is not a KDecor::BaseDecorator' unless decorator.is_a?(KDecor::BaseDecorator) decorator end |