Class: SimpleEnumeration::Collections::BasicFactory
- Inherits:
-
Object
- Object
- SimpleEnumeration::Collections::BasicFactory
- Defined in:
- lib/simple_enumeration/collections/basic_factory.rb
Instance Attribute Summary collapse
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
-
#enum_class ⇒ Object
readonly
Returns the value of attribute enum_class.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(enum_class:, definitions:) ⇒ BasicFactory
constructor
A new instance of BasicFactory.
Constructor Details
#initialize(enum_class:, definitions:) ⇒ BasicFactory
Returns a new instance of BasicFactory.
8 9 10 11 |
# File 'lib/simple_enumeration/collections/basic_factory.rb', line 8 def initialize(enum_class:, definitions:) @enum_class = enum_class @definitions = definitions end |
Instance Attribute Details
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
6 7 8 |
# File 'lib/simple_enumeration/collections/basic_factory.rb', line 6 def definitions @definitions end |
#enum_class ⇒ Object (readonly)
Returns the value of attribute enum_class.
6 7 8 |
# File 'lib/simple_enumeration/collections/basic_factory.rb', line 6 def enum_class @enum_class end |
Class Method Details
.call(*params, **options, &block) ⇒ Object
13 14 15 |
# File 'lib/simple_enumeration/collections/basic_factory.rb', line 13 def self.call(*params, **, &block) new(*params, **).call(&block) end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/simple_enumeration/collections/basic_factory.rb', line 17 def call collection = Collection.new(name: :basic) CollectionMethodsDefiner.call(enum_class: enum_class, collection: collection) definitions.each do |definition| type = TypeBuilder.call(definition: definition, enum_class: enum_class) TypeMethodsDefiner.call(enum_class: enum_class, collection: collection, type: type) collection.add_type(type.value, type) end collection end |