Class: EimXML::XHTML::FORM

Inherits:
Simple show all
Defined in:
lib/eim_xml/xhtml.rb

Constant Summary

Constants inherited from Element

Element::NEST

Instance Attribute Summary

Attributes inherited from Element

#attributes, #contents, #name

Instance Method Summary collapse

Methods inherited from Element

#==, #[], #add, #add_attribute, #del_attribute, #find, #has?, #match, #name_and_attributes, #pcstring_contents, #write_to

Constructor Details

#initialize(attributes = {}) ⇒ FORM

Returns a new instance of FORM.



58
59
60
61
62
63
64
65
66
# File 'lib/eim_xml/xhtml.rb', line 58

def initialize(attributes = {})
  if attributes && (s = attributes.delete(:session))
    name = attributes.delete(:session_name) || 'token'
    require 'digest/sha1'
    token = s[name] ||= Digest::SHA1.hexdigest("#{$PID}#{Time.now}#{rand}")
  end
  super
  add(HIDDEN.new(name:, value: token)) if token
end