Class: SSHTunnel::UI::Forms::ApplicationForm
- Inherits:
-
Object
- Object
- SSHTunnel::UI::Forms::ApplicationForm
- Includes:
- ActiveModel::Model, ActiveModel::Validations::Callbacks
- Defined in:
- lib/ssh-hull/ui/forms/application_form.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(model) ⇒ ApplicationForm
constructor
A new instance of ApplicationForm.
- #save ⇒ Object
- #submit(params) ⇒ Object
Constructor Details
#initialize(model) ⇒ ApplicationForm
Returns a new instance of ApplicationForm.
34 35 36 |
# File 'lib/ssh-hull/ui/forms/application_form.rb', line 34 def initialize(model) @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
13 14 15 |
# File 'lib/ssh-hull/ui/forms/application_form.rb', line 13 def model @model end |
Class Method Details
.attribute(name, opts = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/ssh-hull/ui/forms/application_form.rb', line 17 def attribute(name, opts = {}) self.attributes ||= [] create_attribute(name, opts) self.attributes += [name] end |
Instance Method Details
#save ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/ssh-hull/ui/forms/application_form.rb', line 49 def save self.class.attributes.each do |attr| value = __send__(attr) method = "#{attr}=" model.__send__(method, value) end model end |
#submit(params) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/ssh-hull/ui/forms/application_form.rb', line 39 def submit(params) self.class.attributes.each do |attr| if params[attr] method = "#{attr}=" __send__(method, params[attr]) end end end |