Class: Gitlab::Config::Entry::Factory
- Inherits:
-
Object
- Object
- Gitlab::Config::Entry::Factory
- Defined in:
- lib/gitlab/config/entry/factory.rb
Overview
Factory class responsible for fabricating entry objects.
Constant Summary collapse
- InvalidFactory =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#entry_class ⇒ Object
readonly
Returns the value of attribute entry_class.
Instance Method Summary collapse
- #create! ⇒ Object
- #deprecation ⇒ Object
- #description ⇒ Object
- #inherit ⇒ Object
- #inheritable? ⇒ Boolean
-
#initialize(entry_class) ⇒ Factory
constructor
A new instance of Factory.
- #metadata(metadata) ⇒ Object
- #reserved? ⇒ Boolean
- #value(value) ⇒ Object
- #with(attributes) ⇒ Object
Constructor Details
#initialize(entry_class) ⇒ Factory
Returns a new instance of Factory.
14 15 16 17 18 |
# File 'lib/gitlab/config/entry/factory.rb', line 14 def initialize(entry_class) @entry_class = entry_class @metadata = {} @attributes = { default: entry_class.default } end |
Instance Attribute Details
#entry_class ⇒ Object (readonly)
Returns the value of attribute entry_class.
12 13 14 |
# File 'lib/gitlab/config/entry/factory.rb', line 12 def entry_class @entry_class end |
Instance Method Details
#create! ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/gitlab/config/entry/factory.rb', line 55 def create! raise InvalidFactory unless defined?(@value) ## # We assume that unspecified entry is undefined. # See issue #18775. # if @value.nil? Entry::Unspecified.new(fabricate_unspecified) else fabricate(entry_class, @value) end end |
#deprecation ⇒ Object
35 36 37 |
# File 'lib/gitlab/config/entry/factory.rb', line 35 def deprecation @attributes[:deprecation] end |
#description ⇒ Object
39 40 41 |
# File 'lib/gitlab/config/entry/factory.rb', line 39 def description @attributes[:description] end |
#inherit ⇒ Object
43 44 45 |
# File 'lib/gitlab/config/entry/factory.rb', line 43 def inherit @attributes[:inherit] end |
#inheritable? ⇒ Boolean
47 48 49 |
# File 'lib/gitlab/config/entry/factory.rb', line 47 def inheritable? @attributes[:inherit] end |
#metadata(metadata) ⇒ Object
25 26 27 28 |
# File 'lib/gitlab/config/entry/factory.rb', line 25 def () @metadata.merge!(.compact) self end |
#reserved? ⇒ Boolean
51 52 53 |
# File 'lib/gitlab/config/entry/factory.rb', line 51 def reserved? @attributes[:reserved] end |
#value(value) ⇒ Object
20 21 22 23 |
# File 'lib/gitlab/config/entry/factory.rb', line 20 def value(value) @value = value self end |
#with(attributes) ⇒ Object
30 31 32 33 |
# File 'lib/gitlab/config/entry/factory.rb', line 30 def with(attributes) @attributes.merge!(attributes.compact) self end |