Class: MHVAC::UpgradeForm

Inherits:
Common::Form show all
Includes:
ActiveModel::Validations
Defined in:
lib/mhv_ac/upgrade_form.rb

Overview

Models a MHVAC (MyHealtheVet Account Creation) upgrade form.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#form_signed_date_timeCommon::HTTPDate

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mhv_ac/upgrade_form.rb', line 21

class UpgradeForm < Common::Form
  include ActiveModel::Validations

  attribute :user_id, Integer
  attribute :form_signed_date_time, Common::HTTPDate
  attribute :form_upgrade_manual_date, Common::HTTPDate
  attribute :form_upgrade_online_date, Common::HTTPDate
  attribute :terms_version, String

  validates :user_id, :terms_version, :form_signed_date_time, presence: true

  ##
  # Validates form attributes and wraps each present attribute to create
  # a parameter set for MHV, stripping attribute values of nil.
  #
  # @raise [Common::Exceptions::ValidationErrors] if there are validation errors
  # @return [Hash] A hash of valid form attributes
  #
  def mhv_params
    raise Common::Exceptions::ValidationErrors, self unless valid?

    attribute_set.map do |attribute|
      value = send(attribute.name)
      [attribute.name, value] unless value.nil?
    end.compact.to_h
  end
end

#form_upgrade_manual_dateCommon::HTTPDate

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mhv_ac/upgrade_form.rb', line 21

class UpgradeForm < Common::Form
  include ActiveModel::Validations

  attribute :user_id, Integer
  attribute :form_signed_date_time, Common::HTTPDate
  attribute :form_upgrade_manual_date, Common::HTTPDate
  attribute :form_upgrade_online_date, Common::HTTPDate
  attribute :terms_version, String

  validates :user_id, :terms_version, :form_signed_date_time, presence: true

  ##
  # Validates form attributes and wraps each present attribute to create
  # a parameter set for MHV, stripping attribute values of nil.
  #
  # @raise [Common::Exceptions::ValidationErrors] if there are validation errors
  # @return [Hash] A hash of valid form attributes
  #
  def mhv_params
    raise Common::Exceptions::ValidationErrors, self unless valid?

    attribute_set.map do |attribute|
      value = send(attribute.name)
      [attribute.name, value] unless value.nil?
    end.compact.to_h
  end
end

#form_upgrade_online_dateCommon::HTTPDate

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mhv_ac/upgrade_form.rb', line 21

class UpgradeForm < Common::Form
  include ActiveModel::Validations

  attribute :user_id, Integer
  attribute :form_signed_date_time, Common::HTTPDate
  attribute :form_upgrade_manual_date, Common::HTTPDate
  attribute :form_upgrade_online_date, Common::HTTPDate
  attribute :terms_version, String

  validates :user_id, :terms_version, :form_signed_date_time, presence: true

  ##
  # Validates form attributes and wraps each present attribute to create
  # a parameter set for MHV, stripping attribute values of nil.
  #
  # @raise [Common::Exceptions::ValidationErrors] if there are validation errors
  # @return [Hash] A hash of valid form attributes
  #
  def mhv_params
    raise Common::Exceptions::ValidationErrors, self unless valid?

    attribute_set.map do |attribute|
      value = send(attribute.name)
      [attribute.name, value] unless value.nil?
    end.compact.to_h
  end
end

#terms_versionString

Returns:

  • (String)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mhv_ac/upgrade_form.rb', line 21

class UpgradeForm < Common::Form
  include ActiveModel::Validations

  attribute :user_id, Integer
  attribute :form_signed_date_time, Common::HTTPDate
  attribute :form_upgrade_manual_date, Common::HTTPDate
  attribute :form_upgrade_online_date, Common::HTTPDate
  attribute :terms_version, String

  validates :user_id, :terms_version, :form_signed_date_time, presence: true

  ##
  # Validates form attributes and wraps each present attribute to create
  # a parameter set for MHV, stripping attribute values of nil.
  #
  # @raise [Common::Exceptions::ValidationErrors] if there are validation errors
  # @return [Hash] A hash of valid form attributes
  #
  def mhv_params
    raise Common::Exceptions::ValidationErrors, self unless valid?

    attribute_set.map do |attribute|
      value = send(attribute.name)
      [attribute.name, value] unless value.nil?
    end.compact.to_h
  end
end

#user_idInteger

Returns:

  • (Integer)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mhv_ac/upgrade_form.rb', line 21

class UpgradeForm < Common::Form
  include ActiveModel::Validations

  attribute :user_id, Integer
  attribute :form_signed_date_time, Common::HTTPDate
  attribute :form_upgrade_manual_date, Common::HTTPDate
  attribute :form_upgrade_online_date, Common::HTTPDate
  attribute :terms_version, String

  validates :user_id, :terms_version, :form_signed_date_time, presence: true

  ##
  # Validates form attributes and wraps each present attribute to create
  # a parameter set for MHV, stripping attribute values of nil.
  #
  # @raise [Common::Exceptions::ValidationErrors] if there are validation errors
  # @return [Hash] A hash of valid form attributes
  #
  def mhv_params
    raise Common::Exceptions::ValidationErrors, self unless valid?

    attribute_set.map do |attribute|
      value = send(attribute.name)
      [attribute.name, value] unless value.nil?
    end.compact.to_h
  end
end

Instance Method Details

#mhv_paramsHash

Validates form attributes and wraps each present attribute to create a parameter set for MHV, stripping attribute values of nil.

Returns:

  • (Hash)

    A hash of valid form attributes

Raises:



39
40
41
42
43
44
45
46
# File 'lib/mhv_ac/upgrade_form.rb', line 39

def mhv_params
  raise Common::Exceptions::ValidationErrors, self unless valid?

  attribute_set.map do |attribute|
    value = send(attribute.name)
    [attribute.name, value] unless value.nil?
  end.compact.to_h
end