Class: SimpleEnumeration::Types::BaseFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_enumeration/types/base_factory.rb

Direct Known Subclasses

HashFactory, StringFactory

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enum_class:, definition:) ⇒ BaseFactory

Returns a new instance of BaseFactory.



8
9
10
11
# File 'lib/simple_enumeration/types/base_factory.rb', line 8

def initialize(enum_class:, definition:)
  @enum_class = enum_class
  @definition = definition
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



6
7
8
# File 'lib/simple_enumeration/types/base_factory.rb', line 6

def definition
  @definition
end

#enum_classObject (readonly)

Returns the value of attribute enum_class.



6
7
8
# File 'lib/simple_enumeration/types/base_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/types/base_factory.rb', line 13

def self.call(*params, **options, &block)
  new(*params, **options).call(&block)
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
# File 'lib/simple_enumeration/types/base_factory.rb', line 17

def call
  Type.new(
    definition: definition,
    value: value,
    converted_value: converted_value,
    enum_class: enum_class
  )
end