Class: Stormpath::Rails::RegistrationForm

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/forms/stormpath/rails/registration_form.rb

Defined Under Namespace

Classes: ArbitraryDataSubmitted, FormError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ RegistrationForm

Returns a new instance of RegistrationForm.



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/forms/stormpath/rails/registration_form.rb', line 20

def initialize(params = {})
  custom_data_params = params[:customData] || {}
  params = params.except(:customData).merge(custom_data_params)
  params = params.stringify_keys.transform_keys(&:underscore).symbolize_keys

  arbitrary_param_names = params.keys - RegistrationFormFields.enabled_field_names.push(:organization_name_key)

  if arbitrary_param_names.any?
    raise ArbitraryDataSubmitted, "Can't submit arbitrary data: #{arbitrary_param_names.join(', ')}"
  end

  super(params)
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



6
7
8
# File 'app/forms/stormpath/rails/registration_form.rb', line 6

def 
  @account
end

#organization_name_keyObject

Returns the value of attribute organization_name_key.



6
7
8
# File 'app/forms/stormpath/rails/registration_form.rb', line 6

def organization_name_key
  @organization_name_key
end

Instance Method Details

#saveObject



34
35
36
37
38
39
40
41
42
# File 'app/forms/stormpath/rails/registration_form.rb', line 34

def save
  return false if invalid?

  begin
    self. = 
  rescue Stormpath::Error => error
    errors.add(:base, error.message) && false
  end
end

#save!Object

Raises:



44
45
46
47
# File 'app/forms/stormpath/rails/registration_form.rb', line 44

def save!
  return true if save
  raise(FormError, errors.full_messages.first)
end