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