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
19 20 21 22 23 24 25 |
# File 'lib/hanami/components/component.rb', line 19 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
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hanami/components/component.rb', line 33 def call(configuration) resolve_requirements _prepare.call(configuration) unless _run.nil? _run.call(configuration) return end resolved(name, _resolve.call(configuration)) end |