Class: Calagator::Event::Cloner

Inherits:
Struct
  • Object
show all
Defined in:
app/models/calagator/event/cloner.rb

Constant Summary collapse

ATTRIBUTES =
%i[title description venue_id url venue_details].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#eventObject

Returns the value of attribute event

Returns:

  • (Object)

    the current value of event



8
9
10
# File 'app/models/calagator/event/cloner.rb', line 8

def event
  @event
end

Class Method Details

.clone(event) ⇒ Object



9
10
11
# File 'app/models/calagator/event/cloner.rb', line 9

def self.clone(event)
  new(event).clone
end

Instance Method Details

#cloneObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/calagator/event/cloner.rb', line 15

def clone
  clone = Event.new
  ATTRIBUTES.each do |attribute|
    clone.send "#{attribute}=", event.send(attribute)
  end
  if event.start_time
    clone.start_time = clone_time_for_today(event.start_time)
  end
  clone.end_time = clone_time_for_today(event.end_time) if event.end_time
  if event.tag_list
    clone.tag_list.add(event.tag_list)
  end
  clone
end