Module: Ccp::Commands::Resolvable

Included in:
Composite::CommandManager
Defined in:
lib/ccp/commands/resolvable.rb

Instance Method Summary collapse

Instance Method Details

#resolve(klass) ⇒ Object

Raises:



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ccp/commands/resolvable.rb', line 4

def resolve(klass)
  klass.is_a?(Class) or
    raise CommandNotFound, "expected Class or Module, but got #{klass.class}"

  if klass.ancestors.include?(Commands::Core)
    return klass # ok
  end

  if klass.must.duck?("#execute")
    # dynamically assign core
    klass.class_eval{ include Commands::Core }
    return klass
  end

  raise CommandNotFound, "#{klass} found but it misses 'execute' method"
end