Class: SuperForm::Basic
- Inherits:
-
Object
- Object
- SuperForm::Basic
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion, ActiveModel::Model, ActiveModel::Validations
- Defined in:
- lib/super_form/basic.rb
Class Method Summary collapse
- .form_name(name) ⇒ Object
-
.i18n_prefix(i18n_scope) ⇒ Object
定義 i18n scope.
-
.i18n_scope ⇒ Object
default is forms.
Instance Method Summary collapse
Class Method Details
.form_name(name) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/super_form/basic.rb', line 17 def form_name(name) # 定義 form name (給 form 用的) define_singleton_method :model_name do active_model_name_for(name.to_s.camelize) end end |
.i18n_prefix(i18n_scope) ⇒ Object
定義 i18n scope
30 31 32 33 34 |
# File 'lib/super_form/basic.rb', line 30 def i18n_prefix(i18n_scope) define_singleton_method :i18n_scope do i18n_scope.to_sym end end |
.i18n_scope ⇒ Object
default is forms
25 26 27 |
# File 'lib/super_form/basic.rb', line 25 def i18n_scope :forms end |
Instance Method Details
#sync_params(params) ⇒ Object
10 11 12 13 14 |
# File 'lib/super_form/basic.rb', line 10 def sync_params(params) params.each do |attr, value| public_send("#{attr}=", value) if respond_to?("#{attr}=") end end |