# File app/models/smerf_file.rb, line 98 def initialize(code) # Get the form file name after making sure the file exists @smerf_file_name = SmerfFile.file_exists?(code) @code = code # Load form data from YAML file raw_data = YAML::load(File.open("#{RAILS_ROOT}/#{@smerf_file_name}" )) # Call the base class and pass in some values super(raw_data, "", @@class_code_array, nil) # Make sure smerf key specified, without it we do not have a form check_for_errors(validate_field(@raw_data, 'smerfform', "")) # Set data variables @item_data = @raw_data['smerfform'] @item_tag = 'smerfform' # Array to hold codes for all items for this class, we use this to check for # duplicates, for example duplicate question codes as question codes must be # unique for the complete form @class_code_array = Array.new # Clear all class variables for new file self.clear() # On load of form make sure to clear form index array so that it is # ready to accept entries for the current form SmerfItem.object_index.clear() # Same for validations array SmerfItem.object_validations.clear() end