module NfeReader::AttributeHelper

Constants

WITHELIST

Public Instance Methods

attributes() click to toggle source
# File lib/nfe_reader/helpers/attribute_helper.rb, line 3
def attributes
  @attributes ||= attributes_to_hash
end
attributes_to_hash() click to toggle source
# File lib/nfe_reader/helpers/attribute_helper.rb, line 9
def attributes_to_hash
  attrs = Hash.new

  instance_variables.each do |var|
    key   = var.to_s.gsub /^@/, ''
    value = instance_variable_get(var)

    if [String, Hash].include?(value.class) || WITHELIST.include?(key)
      attrs[key] = value
    end
  end

  attrs
end