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