Class: ChronicTree::Command::AddRootElement

Inherits:
Object
  • Object
show all
Defined in:
lib/chronic_tree/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ AddRootElement

Returns a new instance of AddRootElement.



7
8
9
# File 'lib/chronic_tree/command.rb', line 7

def initialize(source)
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



5
6
7
# File 'lib/chronic_tree/command.rb', line 5

def source
  @source
end

Instance Method Details

#doObject



11
12
13
14
15
16
17
18
19
# File 'lib/chronic_tree/command.rb', line 11

def do
  source.send("elements_under_#{source.current_scope_name}_root").create(
    child: source,
    parent: source,
    distance: 0,
    start_time: source.current_time_at,
    end_time: 1000.years.since(source.current_time_at)
  )
end