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(*args) ⇒ Object
INSTANCE METHODS.
Methods included from Includer
Instance Method Details
#as_json ⇒ Object
33 34 35 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb', line 33 def as_json doc end |
#doc ⇒ nil, Hash
Returns the underlying Hash model as is (carrying current changes).
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb', line 43 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.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb', line 59 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
37 38 39 40 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb', line 37 def print_pretty puts JSON.pretty_generate(as_json) self end |
#to_json(*args) ⇒ Object
INSTANCE METHODS
29 30 31 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb', line 29 def to_json(*args) doc.to_json(*args) end |