Module: AttributeHelper

Instance Method Summary collapse

Instance Method Details

#attributesObject



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

def attributes
  @attributes ||= attributes_to_hash
end

#attributes_to_hashObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/helpers/attribute_helper.rb', line 6

def attributes_to_hash
  attrs = Hash.new

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

    attrs[key] = value if [String, Hash].include? value.class
  end

  attrs
end