Class: Struct

Inherits:
Object show all
Defined in:
lib/active_support/json/encoding.rb,
lib/active_support/core_ext/struct.rb

Overview

Backport of Struct#to_h from Ruby 2.0

Instance Method Summary collapse

Instance Method Details

#as_json(options = nil) ⇒ Object



157
158
159
# File 'lib/active_support/json/encoding.rb', line 157

def as_json(options = nil)
  Hash[members.zip(values)]
end

#to_hObject



3
4
5
# File 'lib/active_support/core_ext/struct.rb', line 3

def to_h
  Hash[members.zip(values)]
end