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’
105
106
107
108
109
110
111
|
# File 'lib/app/models/concerns/core_system_configuration.rb', line 105
def method_missing(method, *args, &_block)
if configuration.respond_to?(method)
configuration.send(method, *args)
else
super
end
end
|
Instance Method Details
#configuration ⇒ Object
87
88
89
|
# File 'lib/app/models/concerns/core_system_configuration.rb', line 87
def configuration
SystemConfiguration.find_or_create_by!(environment: Rails.env)
end
|
#respond_to?(method_name, include_private = false) ⇒ Boolean
113
114
115
|
# File 'lib/app/models/concerns/core_system_configuration.rb', line 113
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
117
118
119
|
# File 'lib/app/models/concerns/core_system_configuration.rb', line 117
def respond_to_missing?(method_name, include_private = false)
configuration.respond_to?(method_name, include_private) || super
end
|
#smtp_configuration ⇒ Object
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/app/models/concerns/core_system_configuration.rb', line 91
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
|