Sha256: 88635a831b5e1c5e57c527fa5012c6400afed25d8952aac81e48c9cc1ba321da
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
module Dry::Initializer::Plugins # Base class for plugins # # A plugin should has class method [.call] that takes argument name and # settings and return a chunk of code for the #initialize method body. # class Base include Dry::Initializer::Errors # Builds the proc for the `__after_initializer__` callback # # @param [#to_s] name # @param [Hash<Symbol, Object>] settings # # @return [String, Proc, nil] # def self.call(name, settings) new(name, settings).call end # @private attr_reader :name, :settings # Initializes a builder with argument name and settings # @param (see .call) def initialize(name, settings) @name = name @settings = settings end # Checks equality to another instance by name # @return [Boolean] def ==(other) other.instance_of?(self.class) && (other.name == name) end # Builds a chunk of code # @return (see .call) def call; end # Returns the name for the attribute # @return (see .name) def rename @rename ||= settings[:option] ? (settings[:as] || name) : name end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry-initializer-0.11.0 | lib/dry/initializer/plugins/base.rb |
dry-initializer-0.10.2 | lib/dry/initializer/plugins/base.rb |
dry-initializer-0.10.1 | lib/dry/initializer/plugins/base.rb |