Class: MVCLI::Cortex

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mvcli/cortex.rb

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Cortex

Returns a new instance of Cortex.

Yields:

  • (_self)

Yield Parameters:

  • _self (MVCLI::Cortex)

    the object that the method was called on



7
8
9
10
# File 'lib/mvcli/cortex.rb', line 7

def initialize
  @cores = []
  yield self if block_given?
end

Instance Method Details

#<<(core) ⇒ Object



16
17
18
19
20
# File 'lib/mvcli/cortex.rb', line 16

def <<(core)
  tap do
    @cores << core
  end
end

#activate!Object



12
13
14
# File 'lib/mvcli/cortex.rb', line 12

def activate!
  each(&:activate!)
end

#each(&block) ⇒ Object



22
23
24
# File 'lib/mvcli/cortex.rb', line 22

def each(&block)
  @cores.each &block
end

#exists?(extension_point, extension_name) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/mvcli/cortex.rb', line 26

def exists?(extension_point, extension_name)
  @cores.detect {|core| core.exists? extension_point, extension_name }
end

#read(extension_point, extension_name) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/mvcli/cortex.rb', line 30

def read(extension_point, extension_name)
  if core = exists?(extension_point, extension_name)
    core.read extension_point, extension_name
  else
    fail MVCLI::ExtensionNotFound, "unable to find #{extension_point} '#{extension_name}'"
  end
end