Class: Dry::Container::Item
- Inherits:
-
Object
- Object
- Dry::Container::Item
- Defined in:
- lib/dry/container/item.rb,
lib/dry/container/item/factory.rb,
lib/dry/container/item/callable.rb,
lib/dry/container/item/memoizable.rb
Overview
Base class to abstract Memoizable and Callable implementations
Direct Known Subclasses
Defined Under Namespace
Classes: Callable, Factory, Memoizable
Instance Attribute Summary collapse
-
#item ⇒ Mixed
readonly
The item to be solved later.
-
#options ⇒ Hash
readonly
The options to memoize, call or no.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(item, options = {}) ⇒ Item
constructor
A new instance of Item.
Constructor Details
#initialize(item, options = {}) ⇒ Item
Returns a new instance of Item.
15 16 17 18 19 20 |
# File 'lib/dry/container/item.rb', line 15 def initialize(item, = {}) @item = item @options = { call: item.is_a?(::Proc) && item.parameters.empty? }.merge() end |
Instance Attribute Details
#item ⇒ Mixed (readonly)
Returns the item to be solved later.
9 10 11 |
# File 'lib/dry/container/item.rb', line 9 def item @item end |
#options ⇒ Hash (readonly)
Returns the options to memoize, call or no.
12 13 14 |
# File 'lib/dry/container/item.rb', line 12 def @options end |
Instance Method Details
#call ⇒ Object
23 24 25 |
# File 'lib/dry/container/item.rb', line 23 def call raise NotImplementedError end |