Class: Hanami::Components::Component Private
- Inherits:
-
Object
- Object
- Hanami::Components::Component
- Defined in:
- lib/hanami/components/component.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Base component
Instance Method Summary collapse
-
#call(configuration) ⇒ Object
private
Run or resolve the component.
-
#initialize(name, &blk) ⇒ Hanami::Components::Component
constructor
private
Instantiate a new component.
Constructor Details
#initialize(name, &blk) ⇒ Hanami::Components::Component
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instantiate a new component
21 22 23 24 25 26 27 |
# File 'lib/hanami/components/component.rb', line 21 def initialize(name, &blk) @name = name @requirements = [] @_prepare = ->(*) {} @_resolve = -> {} instance_eval(&blk) end |
Instance Method Details
#call(configuration) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run or resolve the component
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/hanami/components/component.rb', line 35 def call(configuration) resolve_requirements _prepare.call(configuration) unless _run.nil? _run.call(configuration) return end resolved(name, _resolve.call(configuration)) end |