Sha256: 3e89aa64bc7f3cb7d0b7c7f830b7fd371d2a70648df361a12ac08f7436efb935
Contents?: true
Size: 660 Bytes
Versions: 2
Compression:
Stored size: 660 Bytes
Contents
module Dry::Initializer::Plugins # Plugin builds a chunk of code for the initializer's signature: # # @example # Signature.call(:user) # # => "user" # # Signature.call(:user, default: -> { nil }) # # => "user = Dry::Initializer::UNDEFINED" # # Signature.call(:user, option: true) # # => "**__options__" # class Signature < Base def param? settings[:option] != true end def required? !settings.key?(:default) && !settings[:optional] end def call return "**__options__" unless param? return name.to_s if required? "#{name} = Dry::Initializer::UNDEFINED" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-0.8.1 | lib/dry/initializer/plugins/signature.rb |
dry-initializer-0.8.0 | lib/dry/initializer/plugins/signature.rb |