Class: Backend::TranslationWithSeoForm
- Inherits:
-
Udongo::Form
- Object
- Udongo::Form
- Backend::TranslationWithSeoForm
- Defined in:
- app/forms/backend/translation_with_seo_form.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#seo ⇒ Object
readonly
Returns the value of attribute seo.
-
#translation ⇒ Object
readonly
Returns the value of attribute translation.
Instance Method Summary collapse
-
#initialize(model, translation, seo) ⇒ TranslationWithSeoForm
constructor
A new instance of TranslationWithSeoForm.
- #non_seo_attributes ⇒ Object
- #persisted? ⇒ Boolean
- #save(params) ⇒ Object
- #seo_attributes ⇒ Object
Methods inherited from Udongo::Form
#init_attribute_values, #init_object_values, #save!
Constructor Details
#initialize(model, translation, seo) ⇒ TranslationWithSeoForm
Returns a new instance of TranslationWithSeoForm.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/forms/backend/translation_with_seo_form.rb', line 13 def initialize(model, translation, seo) @model = model @translation = translation @seo = seo non_seo_attributes.each do |f| self.send "#{f}=", @translation.send(f) end seo_attributes.each do |f| self.send("seo_#{f}=", @seo.send(f)) end end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
2 3 4 |
# File 'app/forms/backend/translation_with_seo_form.rb', line 2 def model @model end |
#seo ⇒ Object (readonly)
Returns the value of attribute seo.
2 3 4 |
# File 'app/forms/backend/translation_with_seo_form.rb', line 2 def seo @seo end |
#translation ⇒ Object (readonly)
Returns the value of attribute translation.
2 3 4 |
# File 'app/forms/backend/translation_with_seo_form.rb', line 2 def translation @translation end |
Instance Method Details
#non_seo_attributes ⇒ Object
52 53 54 |
# File 'app/forms/backend/translation_with_seo_form.rb', line 52 def non_seo_attributes attributes.keys.select { |k| !k.to_s.starts_with?('seo_') } end |
#persisted? ⇒ Boolean
27 28 29 |
# File 'app/forms/backend/translation_with_seo_form.rb', line 27 def persisted? true end |
#save(params) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/forms/backend/translation_with_seo_form.rb', line 31 def save(params) non_seo_attributes.each do |f| self.send "#{f}=", params[f.to_sym] end seo_attributes.each do |f| self.send("seo_#{f}=", params["seo_#{f}".to_sym]) end if valid? save_object true else false end end |
#seo_attributes ⇒ Object
48 49 50 |
# File 'app/forms/backend/translation_with_seo_form.rb', line 48 def seo_attributes %w(title keywords description custom slug) end |