Module: CoreSystemConfiguration::ClassMethods
- Defined in:
- lib/app/models/concerns/core_system_configuration.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &_block) ⇒ Object
NOTE: Currently ignored Codacy issue: When using ‘method_missing’, fall back on ‘super’
103
104
105
106
107
108
109
|
# File 'lib/app/models/concerns/core_system_configuration.rb', line 103
def method_missing(method, *args, &_block)
if configuration.respond_to?(method)
configuration.send(method, *args)
else
super
end
end
|
Instance Method Details
#configuration ⇒ Object
85
86
87
|
# File 'lib/app/models/concerns/core_system_configuration.rb', line 85
def configuration
SystemConfiguration.find_or_create_by!(environment: Rails.env)
end
|
#respond_to?(method_name, include_private = false) ⇒ Boolean
111
112
113
|
# File 'lib/app/models/concerns/core_system_configuration.rb', line 111
def respond_to?(method_name, include_private = false)
configuration.respond_to?(method_name, include_private) || super
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
115
116
117
|
# File 'lib/app/models/concerns/core_system_configuration.rb', line 115
def respond_to_missing?(method_name, include_private = false)
configuration.respond_to?(method_name, include_private) || super
end
|
#smtp_configuration ⇒ Object
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/app/models/concerns/core_system_configuration.rb', line 89
def smtp_configuration
output = {}
config = configuration
fields = %w[name address domain port user_name password enable_starttls_auto]
fields.each do |field|
field_name = "smtp_#{field}".to_sym
output[field.to_sym] = config.send(field_name)
end
output
end
|