Module: Ecoportal::API::Common::Content::DoubleModel::DoubleDoc::LinkableDoc
- Extended by:
- Includer
- Defined in:
- lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb
Defined Under Namespace
Classes: UnlinkedModel
Instance Method Summary collapse
- #as_json ⇒ Object
-
#doc ⇒ nil, Hash
The underlying
Hashmodel as is (carrying current changes). -
#original_doc ⇒ nil, Hash
The
original_docholds the model as is now on server-side. - #print_pretty ⇒ Object
-
#to_json ⇒ Object
INSTANCE METHODS.
Methods included from Includer
Instance Method Details
#as_json ⇒ Object
35 36 37 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb', line 35 def as_json doc end |
#doc ⇒ nil, Hash
Note:
when doc isn't rooted, it relies to the _parent.doc.
This does a doc recursive resolve, where resolved_rooted_doc_key
can only have 1 level at each iteration.
Returns the underlying Hash model as is (carrying current changes).
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb', line 48 def doc return @doc if doc_var? return @doc if root? unless linked? raise UnlinkedModel.new( from: "#{self.class}##{__method__}", key: _parent_key ) end _parent.doc.dig(*resolved_rooted_doc_key) end |
#original_doc ⇒ nil, Hash
The original_doc holds the model as is now on server-side.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb', line 64 def original_doc return @original_doc if root? unless linked? raise UnlinkedModel.new( from: "#{self.class}##{__method__}", key: _parent_key ) end _parent.original_doc.dig(*resolved_rooted_doc_key) end |
#print_pretty ⇒ Object
39 40 41 42 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb', line 39 def print_pretty puts JSON.pretty_generate(as_json) self end |
#to_json ⇒ Object
INSTANCE METHODS
31 32 33 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb', line 31 def to_json(...) doc.to_json(...) end |