Class: OmniCat::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/omnicat/base.rb

Instance Method Summary collapse

Instance Method Details

#to_hashObject

Returns Base object as Hash

Returns:

  • Base object instance variables in a Hash



6
7
8
9
10
11
12
13
14
# File 'lib/omnicat/base.rb', line 6

def to_hash
  hash = {}
  self.instance_variables.each do |key|
    if val = instance_variable_get(key)
      hash[key[1..-1].to_sym] = val.class.to_s.include?('OmniCat') ? val.to_hash : val
    end
  end
  hash
end