Module: NfeReader::AttributeHelper

Constant Summary collapse

WITHELIST =
%w(taxpayer_messages messages seals)

Instance Method Summary collapse

Instance Method Details

#attributesObject



3
4
5
# File 'lib/nfe_reader/helpers/attribute_helper.rb', line 3

def attributes
  @attributes ||= attributes_to_hash
end

#attributes_to_hashObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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