Class: LitleOnline::Contact

Inherits:
Object
  • Object
show all
Includes:
XML::Mapping
Defined in:
lib/XMLFields.rb

Class Method Summary collapse

Class Method Details

.from_hash(hash, name = 'contact') ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/XMLFields.rb', line 153

def self.from_hash(hash, name='contact')
  base = hash[name]
  if(base)
    this = Contact.new
    this.name = base['name']
    this.firstName = base['firstName']
    this.middleInitial = base['middleInitial']
    this.lastName = base['lastName']
    this.companyName = base['companyName']
    this.addressLine1 = base['addressLine1']
    this.addressLine2 = base['addressLine2']
    this.addressLine3 = base['addressLine3']
    this.city = base['city']
    this.state = base['state']
    this.zip = base['zip']
    this.country = base['country']
    this.email = base['email']
    this.phone = base['phone']
    SchemaValidation.validate_length(this.name, false, 1, 100, name, "name")
    SchemaValidation.validate_length(this.firstName, false, 1, 25, name, "firstName")
    SchemaValidation.validate_length(this.middleInitial, false, 1, 1, name, "middleInitial")
    SchemaValidation.validate_length(this.lastName, false, 1, 25, name, "lastName")
    SchemaValidation.validate_length(this.companyName, false, 1, 40, name, "companyName")
    SchemaValidation.validate_length(this.addressLine1, false, 1, 35, name, "addressLine1")
    SchemaValidation.validate_length(this.addressLine2, false, 1, 35, name, "addressLine2")
    SchemaValidation.validate_length(this.addressLine3, false, 1, 35, name, "addressLine3")
    SchemaValidation.validate_length(this.city, false, 1, 35, name, "city")
    SchemaValidation.validate_length(this.state, false, 1, 30, name, "state")
    SchemaValidation.validate_length(this.zip, false, 1, 20, name, "zip")
    SchemaValidation.validate_length(this.country, false, 1, 3, name, "country")
    SchemaValidation.validate_country(this.country, name, "country")
    SchemaValidation.validate_length(this.email, false, 1, 100, name, "email")
    SchemaValidation.validate_length(this.phone, false, 1, 20, name, "phone")
    this
  else
    nil
  end
end