Module: Ecoportal::API::Common::DocHelpers
- Included in:
- BatchOperation, V1::People
- Defined in:
- lib/ecoportal/api/common/doc_helpers.rb
Instance Method Summary collapse
Instance Method Details
#get_body(doc) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/ecoportal/api/common/doc_helpers.rb', line 5 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) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ecoportal/api/common/doc_helpers.rb', line 14 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 |