Class: EasySettings::FormModel
- Defined in:
- lib/redmine_extensions/easy_settings/form_model.rb
Overview
EasySettings::FormModel
Fake models/proxy for easy seettings. Usable in rails form.
settings = EasySettings::FormModel.new(prefix: 'easy_gantt')
settings.show_holidays == EasySetting.value(:easy_gantt_show_holidays)
Instance Method Summary collapse
-
#initialize(prefix: nil, project: nil) ⇒ FormModel
constructor
A new instance of FormModel.
-
#method_missing(name, *args) ⇒ Object
Called for missing :id parameter.
- #model_name ⇒ Object
- #persisted? ⇒ Boolean
- #to_model ⇒ Object
Constructor Details
#initialize(prefix: nil, project: nil) ⇒ FormModel
Returns a new instance of FormModel.
12 13 14 15 |
# File 'lib/redmine_extensions/easy_settings/form_model.rb', line 12 def initialize(prefix: nil, project: nil) @prefix = "#{prefix}_" if prefix.present? @project_id = project.is_a?(Project) ? project.id : project end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
Called for missing :id parameter
def to_param end
34 35 36 |
# File 'lib/redmine_extensions/easy_settings/form_model.rb', line 34 def method_missing(name, *args) EasySetting.value("#{@prefix}#{name}", @project_id) end |
Instance Method Details
#model_name ⇒ Object
17 18 19 |
# File 'lib/redmine_extensions/easy_settings/form_model.rb', line 17 def model_name EasySetting.model_name end |
#persisted? ⇒ Boolean
21 22 23 |
# File 'lib/redmine_extensions/easy_settings/form_model.rb', line 21 def persisted? true end |
#to_model ⇒ Object
25 26 27 |
# File 'lib/redmine_extensions/easy_settings/form_model.rb', line 25 def to_model self end |