Class: Stormpath::Rails::OrganizationForm

Inherits:
Object
  • Object
show all
Defined in:
app/forms/stormpath/rails/organization_form.rb

Defined Under Namespace

Classes: FormError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_key) ⇒ OrganizationForm

Returns a new instance of OrganizationForm.

Raises:



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

def initialize(name_key)
  @name_key = name_key
  raise FormError, "Organization Name Key can't be blank" if name_key.blank?
end

Instance Attribute Details

#name_keyObject (readonly)

Returns the value of attribute name_key.



4
5
6
# File 'app/forms/stormpath/rails/organization_form.rb', line 4

def name_key
  @name_key
end

Instance Method Details

#save!Object



17
18
19
20
21
22
23
24
25
# File 'app/forms/stormpath/rails/organization_form.rb', line 17

def save!
  begin
    Stormpath::Rails::OrganizationResolver.new(
      OpenStruct.new(subdomains: [name_key])
    ).organization
  rescue Stormpath::Rails::OrganizationResolver::Error
    raise FormError, 'Organization could not be found'
  end
end