Class: Struct

Inherits:
Object show all
Defined in:
activesupport/lib/active_support/json/encoding.rb,
activesupport/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


163
164
165
# File 'activesupport/lib/active_support/json/encoding.rb', line 163

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

#to_hObject


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

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