module Ecoportal::API::Common::DocHelpers
Public Instance Methods
get_body(doc)
click to toggle source
# File lib/ecoportal/api/common/doc_helpers.rb, line 6 def get_body(doc) if doc.respond_to?(:as_update) doc.as_update elsif doc.respond_to?(:as_json) doc.as_json else doc end end
get_id(doc)
click to toggle source
# File lib/ecoportal/api/common/doc_helpers.rb, line 16 def get_id(doc) id = nil id ||= doc.id if doc.respond_to?(:id) id ||= doc.external_id if doc.respond_to?(:external_id) id ||= doc["id"] if doc.is_a?(Hash) id ||= doc["external_id"] if doc.is_a?(Hash) id ||= doc if doc.is_a?(String) id or raise "No ID has been given!" id end