Class: Servactory::Inputs::Input
- Inherits:
-
Object
- Object
- Servactory::Inputs::Input
show all
- Defined in:
- lib/servactory/inputs/input.rb
Overview
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Classes: Actor
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, *helpers, as: nil, option_helpers:, **options) ⇒ Input
rubocop:disable Style/KeywordParametersOrder
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/servactory/inputs/input.rb', line 49
def initialize(
name,
*helpers,
as: nil,
option_helpers:,
**options
)
@name = name
@internal_name = as.presence || name
@option_helpers = option_helpers
register_options(helpers:, options:)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
rubocop:enable Style/KeywordParametersOrder
64
65
66
67
68
69
|
# File 'lib/servactory/inputs/input.rb', line 64
def method_missing(name, *args, &block)
option = @collection_of_options.find_by(name:)
return super if option.nil?
option.body
end
|
Instance Attribute Details
#collection_of_options ⇒ Object
Returns the value of attribute collection_of_options.
43
44
45
|
# File 'lib/servactory/inputs/input.rb', line 43
def collection_of_options
@collection_of_options
end
|
#internal_name ⇒ Object
Returns the value of attribute internal_name.
43
44
45
|
# File 'lib/servactory/inputs/input.rb', line 43
def internal_name
@internal_name
end
|
#name ⇒ Object
Returns the value of attribute name.
43
44
45
|
# File 'lib/servactory/inputs/input.rb', line 43
def name
@name
end
|
#options ⇒ Object
Returns the value of attribute options.
43
44
45
|
# File 'lib/servactory/inputs/input.rb', line 43
def options
@options
end
|
Instance Method Details
#conflict_code ⇒ Object
87
88
89
|
# File 'lib/servactory/inputs/input.rb', line 87
def conflict_code
@collection_of_options.defined_conflict_code
end
|
#i18n_name ⇒ Object
95
96
97
|
# File 'lib/servactory/inputs/input.rb', line 95
def i18n_name
system_name.to_s.pluralize
end
|
103
104
105
|
# File 'lib/servactory/inputs/input.rb', line 103
def input?
true
end
|
#internal? ⇒ Boolean
107
108
109
|
# File 'lib/servactory/inputs/input.rb', line 107
def internal?
false
end
|
#options_for_checks ⇒ Object
83
84
85
|
# File 'lib/servactory/inputs/input.rb', line 83
def options_for_checks
@collection_of_options.options_for_checks
end
|
#output? ⇒ Boolean
111
112
113
|
# File 'lib/servactory/inputs/input.rb', line 111
def output?
false
end
|
#register_options(helpers:, options:) ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/servactory/inputs/input.rb', line 75
def register_options(helpers:, options:)
merged_options = augment_options_with_helpers(helpers:, options:)
options_registrar = create_options_registrar(options: merged_options)
@options = merged_options
@collection_of_options = options_registrar.collection
end
|
#respond_to_missing?(name) ⇒ Boolean
71
72
73
|
# File 'lib/servactory/inputs/input.rb', line 71
def respond_to_missing?(name, *)
@collection_of_options.names.include?(name) || super
end
|
#system_name ⇒ Object
91
92
93
|
# File 'lib/servactory/inputs/input.rb', line 91
def system_name
self.class.name.demodulize.downcase.to_sym
end
|
#with_conflicts? ⇒ Boolean
99
100
101
|
# File 'lib/servactory/inputs/input.rb', line 99
def with_conflicts?
conflict_code.present?
end
|