Class: Dry::Initializer::Signature
- Inherits:
-
Object
- Object
- Dry::Initializer::Signature
- Includes:
- Errors, Enumerable
- Defined in:
- lib/dry/initializer/signature.rb
Overview
Immutable container for chunks of code describing argument signatures. Responcible for building the resulting signature for the initializer args.
Instance Method Summary collapse
- #add(*args) ⇒ Object
- #call ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Signature
constructor
A new instance of Signature.
Constructor Details
#initialize ⇒ Signature
Returns a new instance of Signature.
8 9 10 |
# File 'lib/dry/initializer/signature.rb', line 8 def initialize @list = [] end |
Instance Method Details
#add(*args) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/dry/initializer/signature.rb', line 12 def add(*args) signature = Plugins::Signature.new(*args) validates_uniqueness_of signature validates_order_of signature copy { @list += [signature] } end |
#call ⇒ Object
27 28 29 |
# File 'lib/dry/initializer/signature.rb', line 27 def call map(&:call).join(", ") end |
#each ⇒ Object
21 22 23 24 25 |
# File 'lib/dry/initializer/signature.rb', line 21 def each (@list.select(&:param?) + @list.reject(&:param?)).each do |item| yield item end end |