Class: Flexite::BaseForm

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations
Defined in:
app/forms/flexite/base_form.rb

Direct Known Subclasses

Config::Form, Entry::Form

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject (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

Returns:

  • (Boolean)


21
22
23
# File 'app/forms/flexite/base_form.rb', line 21

def new_record?
  !persisted?
end

#persisted?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/forms/flexite/base_form.rb', line 17

def persisted?
  respond_to?(:id) && id.present?
end