Class: Dry::Initializer::Plugins::Base
- Inherits:
-
Object
- Object
- Dry::Initializer::Plugins::Base
- Includes:
- Errors
- Defined in:
- lib/dry/initializer/plugins/base.rb
Overview
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.
Direct Known Subclasses
Instance Attribute Summary collapse
- #name ⇒ Object readonly
- #settings ⇒ Object readonly
Class Method Summary collapse
-
.call(name, settings) ⇒ String, ...
Builds the proc for the ‘after_initializer` callback.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Checks equality to another instance by name.
-
#call ⇒ String, ...
Builds a chunk of code.
-
#initialize(name, settings) ⇒ Base
constructor
Initializes a builder with argument name and settings.
-
#rename ⇒ Object
Returns the name for the attribute.
Constructor Details
#initialize(name, settings) ⇒ Base
Initializes a builder with argument name and settings
26 27 28 29 |
# File 'lib/dry/initializer/plugins/base.rb', line 26 def initialize(name, settings) @name = name @settings = settings end |
Instance Attribute Details
#name ⇒ Object (readonly)
22 23 24 |
# File 'lib/dry/initializer/plugins/base.rb', line 22 def name @name end |
#settings ⇒ Object (readonly)
22 23 24 |
# File 'lib/dry/initializer/plugins/base.rb', line 22 def settings @settings end |
Class Method Details
.call(name, settings) ⇒ String, ...
Builds the proc for the ‘after_initializer` callback
17 18 19 |
# File 'lib/dry/initializer/plugins/base.rb', line 17 def self.call(name, settings) new(name, settings).call end |
Instance Method Details
#==(other) ⇒ Boolean
Checks equality to another instance by name
33 34 35 |
# File 'lib/dry/initializer/plugins/base.rb', line 33 def ==(other) other.instance_of?(self.class) && (other.name == name) end |
#call ⇒ String, ...
Builds a chunk of code
39 40 |
# File 'lib/dry/initializer/plugins/base.rb', line 39 def call end |
#rename ⇒ Object
Returns the name for the attribute
44 45 46 |
# File 'lib/dry/initializer/plugins/base.rb', line 44 def rename @rename ||= settings[:option] ? (settings[:as] || name) : name end |