Class: Cleon::Explorer
- Inherits:
-
Object
- Object
- Cleon::Explorer
- Defined in:
- lib/cleon/explorer.rb
Overview
The class for retrieving services from Cleon's gem
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Array<PortDecor>
For services in @source.
-
#initialize(source) ⇒ Explorer
constructor
A new instance of Explorer.
Constructor Details
#initialize(source) ⇒ Explorer
Returns a new instance of Explorer.
12 13 14 |
# File 'lib/cleon/explorer.rb', line 12 def initialize(source) @source = source end |
Class Method Details
.call(*args, **kwargs) ⇒ Object
8 9 10 |
# File 'lib/cleon/explorer.rb', line 8 def self.call(*args, **kwargs) new(*args, **kwargs).call end |
Instance Method Details
#call ⇒ Array<PortDecor>
Returns for services in @source.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cleon/explorer.rb', line 17 def call require @source const = Module.const_get("#{@source.capitalize}::Services") Cleon.error!("The #{const_name} not found") unless const services = const.constants.filter{|co| co !~ /Service\z/} services.map do |se| klass = const.const_get(se) param = klass.instance_method(:initialize).parameters PortDecor.new(MetaService.new(klass.to_s, param)) end rescue LoadError => e Cleon.error!(e.) end |