Class: Flexite::BaseForm
- Inherits:
-
Object
- Object
- Flexite::BaseForm
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion, ActiveModel::Validations
- Defined in:
- app/forms/flexite/base_form.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ BaseForm
constructor
A new instance of BaseForm.
- #new_record? ⇒ Boolean
- #persisted? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ BaseForm
Returns a new instance of BaseForm.
8 9 10 11 12 13 14 15 |
# File 'app/forms/flexite/base_form.rb', line 8 def initialize(attributes = {}) @attributes = HashWithIndifferentAccess.new attributes.each do |name, value| send("#{name}=", value) rescue next @attributes[name] = value end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'app/forms/flexite/base_form.rb', line 6 def attributes @attributes end |
Instance Method Details
#new_record? ⇒ Boolean
21 22 23 |
# File 'app/forms/flexite/base_form.rb', line 21 def new_record? !persisted? end |
#persisted? ⇒ Boolean
17 18 19 |
# File 'app/forms/flexite/base_form.rb', line 17 def persisted? respond_to?(:id) && id.present? end |