Class: Hanami::Components::Component Private

Inherits:
Object
  • Object
show all
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

See Also:

Since:

  • 0.9.0

Instance Method Summary collapse

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

Since:

  • 0.9.0


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

Since:

  • 0.9.0


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