Class: KDecor::DecoratorHash

Inherits:
Hash
  • Object
show all
Includes:
ResolveInstance, KLog::Logging
Defined in:
lib/k_decor/decorator_hash.rb

Overview

Decorator set will hold a set of instantiated decorators with lookup keys

Instance Method Summary collapse

Methods included from ResolveInstance

#resolve_decorator_instance

Instance Method Details

#add(key, decorator) ⇒ Object

Add a keyed decorator to the store.

Parameters:

  • key (Symbol)

    lookup key that can be used when retrieving the decorator



12
13
14
15
16
17
18
19
20
# File 'lib/k_decor/decorator_hash.rb', line 12

def add(key, decorator)
  if key?(key)
    log.warn("Decorator with this key '#{key}' already in the stored")
    return
  end

  self[key] = resolve_decorator_instance(decorator)
  nil
end