Class: ENM::Enum::DryTypeBuilder Private
- Inherits:
-
Object
- Object
- ENM::Enum::DryTypeBuilder
- Defined in:
- lib/enm/enum.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Builds a Dry::Types::Type for an ENM::Enum.
Instance Attribute Summary collapse
- #default ⇒ String, ... readonly private
Instance Method Summary collapse
- #call ⇒ Dry::Types::Type private
- #default? ⇒ Boolean private
-
#initialize ⇒ DryTypeBuilder
constructor
private
A new instance of DryTypeBuilder.
- #symbol? ⇒ Boolean private
Constructor Details
#initialize ⇒ DryTypeBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DryTypeBuilder.
52 53 54 55 56 |
# File 'lib/enm/enum.rb', line 52 def initialize(...) super @default = derive_real_default end |
Instance Attribute Details
#default ⇒ String, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/enm/enum.rb', line 50 def default @default end |
Instance Method Details
#call ⇒ Dry::Types::Type
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 62 63 64 65 66 67 |
# File 'lib/enm/enum.rb', line 59 def call base = build_base type = default? ? base.default(default.freeze) : base enum_values = symbol? ? enum.map(&:to_sym) : enum.to_a type.enum(*enum_values) end |
#default? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 |
# File 'lib/enm/enum.rb', line 69 def default? = !default_value.nil? |
#symbol? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 |
# File 'lib/enm/enum.rb', line 71 def symbol? = mode == :symbol |