Class: ChronicTree::Command::RemoveChildElementsFromAncestors
- Inherits:
-
Object
- Object
- ChronicTree::Command::RemoveChildElementsFromAncestors
- Defined in:
- lib/chronic_tree/command.rb
Instance Attribute Summary collapse
-
#ancestor_ids ⇒ Object
readonly
Returns the value of attribute ancestor_ids.
-
#child_ids ⇒ Object
readonly
Returns the value of attribute child_ids.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #do ⇒ Object
-
#initialize(source, ancestor_ids, child_ids) ⇒ RemoveChildElementsFromAncestors
constructor
A new instance of RemoveChildElementsFromAncestors.
Constructor Details
#initialize(source, ancestor_ids, child_ids) ⇒ RemoveChildElementsFromAncestors
Returns a new instance of RemoveChildElementsFromAncestors.
56 57 58 59 60 |
# File 'lib/chronic_tree/command.rb', line 56 def initialize(source, ancestor_ids, child_ids) @source = source @ancestor_ids = ancestor_ids @child_ids = child_ids end |
Instance Attribute Details
#ancestor_ids ⇒ Object (readonly)
Returns the value of attribute ancestor_ids.
54 55 56 |
# File 'lib/chronic_tree/command.rb', line 54 def ancestor_ids @ancestor_ids end |
#child_ids ⇒ Object (readonly)
Returns the value of attribute child_ids.
54 55 56 |
# File 'lib/chronic_tree/command.rb', line 54 def child_ids @child_ids end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
54 55 56 |
# File 'lib/chronic_tree/command.rb', line 54 def source @source end |
Instance Method Details
#do ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/chronic_tree/command.rb', line 62 def do ChronicTree::ActiveRecord::Element.at(source.current_time_at). where(tree_type: source.class.name). where(scope_name: source.current_scope_name). where(parent_id: ancestor_ids). where(child_id: child_ids). update_all(end_time: source.current_time_at) end |