def object_from_hash(nsc, hash)
      hash.each do |k, v|
        next if k == :url # Do not store self-referential URL.
        # Store resource URLs separately and create lazy accessors.
        if v.is_a?(Hash) && v.key?(:url)
          self.class.send(:define_method, k, proc { |conn = nsc| load_resource(conn, k, v[:url].gsub(/.*\/api/, '/api')) })
        else
          # Convert timestamps.
          if v.is_a?(String) && v.match(/^\d{8}T\d{6}\.\d{3}/)
            instance_variable_set("@#{k}", ISO8601.to_time(v))
          elsif v.is_a?(Array) && k == :attributes
            instance_variable_set("@#{k}", v.map { |h| { h[:key] => h[:value] } })
          else
            instance_variable_set("@#{k}", v)
          end
          self.class.send(:define_method, k, proc { instance_variable_get("@#{k}") })
        end
      end
      self
    end
def object_from_hash(nsc, hash)
      hash.each do |k, v|
        next if k == :url # Do not store self-referential URL.
        # Store resource URLs separately and create lazy accessors.
        if v.is_a?(Hash) && v.key?(:url)
          self.class.send(:define_method, k, proc { |conn = nsc| load_resource(conn, k, v[:url].gsub(/.*\/api/, '/api')) })
        else
          # Convert timestamps.
          if v.is_a?(String) && v.match(/^\d{8}T\d{6}\.\d{3}/)
            instance_variable_set("@#{k}", ISO8601.to_time(v))
          elsif v.is_a?(Array) && k == :attributes
            instance_variable_set("@#{k}", v.map { |h| { h[:key] => h[:value] } })
          else
            instance_variable_set("@#{k}", v)
          end
          self.class.send(:define_method, k, proc { instance_variable_get("@#{k}") })
        end
      end
      self
    end
Populate object methods and attributes from a JSON-derived hash.

 @param [Nexpose::Connection] nsc Active connection to a console.
 @param [Hash] hash Result of running JSON#parse with the
   symbolize_names parameter to a 2.0 API response.
   Pass hash[:resources] if the response is pageable.