Class: Eco::Data::Locations::NodeDiff
- Inherits:
-
Hashes::DiffResult
- Object
- Hashes::DiffResult
- Eco::Data::Locations::NodeDiff
- Includes:
- Accessors
- Defined in:
- lib/eco/data/locations/node_diff.rb,
lib/eco/data/locations/node_diff/accessors.rb,
lib/eco/data/locations/node_diff/nodes_diff.rb
Overview
this works with Hash
object where basic keys are:
nodeId
name
parentId
archived
other properties can be part of the Hash
although
they may not influence the results.
that for special exposed
methods question mark ?
on a
property of the model checks if that property changed
(it has nothing to do with checking the boolean value of that property)
Differences between node before and after
Direct Known Subclasses
Defined Under Namespace
Modules: Accessors Classes: NodesDiff
Instance Attribute Summary
Attributes inherited from Hashes::DiffResult
Instance Method Summary collapse
-
#archive?(validate: true) ⇒ Boolean
Has the
archived
property changed and it wasfalse
?. - #classifications? ⇒ Boolean
- #classifications_src? ⇒ Object
-
#id_name? ⇒ Boolean
Has any of
id
orname
properties changed?. - #marked_for_unarchive? ⇒ Boolean
-
#move? ⇒ Boolean
Has the parent id changed?.
-
#name? ⇒ Boolean
Has the property
name
changed?. -
#name_src? ⇒ Object
move method, to redefine it.
- #unarchive! ⇒ Object
-
#unarchive? ⇒ Boolean
Has the
archived
property changed and it wastrue
?.
Methods inherited from Hashes::DiffResult
#all_compared_attrs, #all_source_keys, #attr, #attr_prev, #del?, #diff?, #diff_attr?, #diff_attrs, #diff_hash, #dup, #initialize, #key?, #new?, #update?
Methods included from Hashes::DiffResult::Meta
#all_compared_attrs, #case_sensitive?, #key
Constructor Details
This class inherits a constructor from Eco::Data::Hashes::DiffResult
Instance Method Details
#archive?(validate: true) ⇒ Boolean
Has the archived
property changed and it was false
?
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/eco/data/locations/node_diff.rb', line 82 def archive?(validate: true) return false if archived_prev msg = "Value of archived shouldn't be true, " msg << "because node '#{node_id}' doesn't exist " msg << "(it's being inserted). " msg << "It should have been discarded as a diff" raise msg if validate && archived && insert? return true if del? archived end |
#classifications? ⇒ Boolean
should not be part of an insert
39 40 41 |
# File 'lib/eco/data/locations/node_diff.rb', line 39 def classifications? classifications_src? && update? end |
#classifications_src? ⇒ Object
37 |
# File 'lib/eco/data/locations/node_diff.rb', line 37 alias_method :classifications_src?, :classifications? |
#id_name? ⇒ Boolean
Has any of id
or name
properties changed?
50 51 52 53 54 55 |
# File 'lib/eco/data/locations/node_diff.rb', line 50 def id_name? return true if id? return true if name? classifications? end |
#marked_for_unarchive? ⇒ Boolean
68 69 70 |
# File 'lib/eco/data/locations/node_diff.rb', line 68 def marked_for_unarchive? @marked_for_unarchived || false end |
#move? ⇒ Boolean
Has the parent id changed?
58 59 60 61 62 |
# File 'lib/eco/data/locations/node_diff.rb', line 58 def move? return false unless update? parent_id? end |
#name? ⇒ Boolean
should not be part of an insert
Has the property name
changed?
33 34 35 |
# File 'lib/eco/data/locations/node_diff.rb', line 33 def name? name_src? && update? end |
#name_src? ⇒ Object
move method, to redefine it
30 |
# File 'lib/eco/data/locations/node_diff.rb', line 30 alias_method :name_src?, :name? |
#unarchive! ⇒ Object
64 65 66 |
# File 'lib/eco/data/locations/node_diff.rb', line 64 def unarchive! @marked_for_unarchived = true end |
#unarchive? ⇒ Boolean
Has the archived
property changed and it was true
?
73 74 75 76 77 78 79 |
# File 'lib/eco/data/locations/node_diff.rb', line 73 def unarchive? return true if marked_for_unarchive? return false if archived return false unless update? archived? end |