Class: SimpleEnumeration::TypeBuilder
- Inherits:
-
Object
- Object
- SimpleEnumeration::TypeBuilder
- Defined in:
- lib/simple_enumeration/type_builder.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#enum_class ⇒ Object
readonly
Returns the value of attribute enum_class.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #factory_klass ⇒ Object
-
#initialize(enum_class:, definition:) ⇒ TypeBuilder
constructor
A new instance of TypeBuilder.
Constructor Details
#initialize(enum_class:, definition:) ⇒ TypeBuilder
Returns a new instance of TypeBuilder.
7 8 9 10 |
# File 'lib/simple_enumeration/type_builder.rb', line 7 def initialize(enum_class:, definition:) @enum_class = enum_class @definition = definition end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
5 6 7 |
# File 'lib/simple_enumeration/type_builder.rb', line 5 def definition @definition end |
#enum_class ⇒ Object (readonly)
Returns the value of attribute enum_class.
5 6 7 |
# File 'lib/simple_enumeration/type_builder.rb', line 5 def enum_class @enum_class end |
Class Method Details
.call(*params, **options, &block) ⇒ Object
12 13 14 |
# File 'lib/simple_enumeration/type_builder.rb', line 12 def self.call(*params, **, &block) new(*params, **).call(&block) end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 |
# File 'lib/simple_enumeration/type_builder.rb', line 16 def call factory_klass.call( enum_class: enum_class, definition: definition ) end |
#factory_klass ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/simple_enumeration/type_builder.rb', line 23 def factory_klass if definition.is_a?(Hash) Types::HashFactory else Types::StringFactory end end |