Sha256: 96fd14867f04c26a935d6be879cc0d4f03802212a2521708c9d2b1f8ef14e337

Contents?: true

Size: 777 Bytes

Versions: 4

Compression:

Stored size: 777 Bytes

Contents

require 'noko_hacks'
module XmlToForm
  class XmlHandler < ActiveRecord::Base
    include ActiveModel::Model
    extend NokoHacks
    extend ActiveModel::Callbacks

    def after_initialize(some_hash)
      some_hash.each do |key, value|
        self.send("#{key}=", value) rescue nil
      end if some_hash.is_a?(Hash)
    end

    def self.noko_meta_data(file)
      xml_obj = Nokogiri::XML(file).remove_namespaces! do |config|
        config.default_xml.noblanks
      end
      xml_obj.children.remove_blank_node
      xml_obj.children.iterate_child_nodes(_node_array= [], attr_accessor_hash ={})
      attr_accessor_hash.each do |attr_key, attr_value|
        attr_accessor attr_key.to_sym
      end
      return _node_array, attr_accessor_hash, xml_obj
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xml_to_form-0.0.4 app/models/xml_to_form/xml_handler.rb
xml_to_form-0.0.3 app/models/xml_to_form/xml_handler.rb
xml_to_form-0.0.2 app/models/xml_to_form/xml_handler.rb
xml_to_form-0.0.1 app/models/xml_to_form/xml_handler.rb