NARKOZ/ginatra

View on GitHub
lib/git/webby/extensions.rb

Summary

Maintainability
A
25 mins
Test Coverage
class Hash
  # Convert to Struct including all values that are Hash class.
  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
end