Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/git/webby/extensions.rb
Instance Method Summary collapse
-
#to_struct ⇒ Object
Convert to Struct including all values that are Hash class.
Instance Method Details
#to_struct ⇒ Object
Convert to Struct including all values that are Hash class.
3 4 5 6 7 8 9 |
# File 'lib/git/webby/extensions.rb', line 3 def to_struct keys = self.keys.sort members = keys.map(&:to_sym) Struct.new(*members).new(*keys.map do |key| (self[key].kind_of? Hash) ? self[key].to_struct : self[key] end) unless self.empty? end |