Class: EasyCallbacks::Utils::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_callbacks/utils/serializer.rb

Class Method Summary collapse

Class Method Details

.to_h(object, attrs = []) ⇒ Object



8
9
10
11
12
13
# File 'lib/easy_callbacks/utils/serializer.rb', line 8

def to_h(object, attrs=[])
  attrs = [attrs] unless attrs.is_a? Array
  hash = {}
  attrs.each { |k| hash[k.to_sym] = object.send k }
  hash
end