 -----END PGP PUBLIC KEY BLOCK-----'''
 ready = ->
   encryptor = new GPGFormEncryptor(armored_key)
-  encryptor.ready()
+  encryptor.setup()
 $(document).ready(ready)
 $(document).on('page:load',ready)


  submit_handler: (e, form) ->
    e.preventDefault()
    values = @get_values(form)
    single_defer = $.Deferred()
    group_defer = $.Deferred()
    @single_encryption(form, values, (result) ->
      single_defer.resolve()
    )
    $.when(single_defer).done(() =>
      @group_encryption(form, values, (result) ->
        group_defer.resolve()
      )
    )
    $.when(single_defer, group_defer).done(() =>
      @reinsert_values values
      form.submit()
    )

  get_values: (form) ->
    return $(form).serializeArray()

  single_encryption: (form, values, callback) ->
    names_to_encrypt = @find_names_for(form, "*[data-encrypt]")
    defers = []
    @encrypt_requested_fields(values, names_to_encrypt, defers)
    $.when.apply($, defers).done(() -> # Spat defers to param list with apply
      callback(values)
    )

  find_names_for: (root, selector) ->

  constructor: (armored_key) ->
    @load_key(armored_key)

  setup: ->
      $("form[data-encrypted-form]").each (index, element) =>
        $(element).submit((e)=>
          @submit_handler(e, element)
