Class: Eventable::OpeningTimelist

Inherits:
Object
  • Object
show all
Defined in:
app/models/eventable/opening_timelist.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opening_period) ⇒ OpeningTimelist

Returns a new instance of OpeningTimelist.



6
7
8
9
# File 'app/models/eventable/opening_timelist.rb', line 6

def initialize(opening_period)
  @opening_period = opening_period
  @items = opening_period.opening_times.all
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



3
4
5
# File 'app/models/eventable/opening_timelist.rb', line 3

def items
  @items
end

#opening_periodObject (readonly)

Returns the value of attribute opening_period.



3
4
5
# File 'app/models/eventable/opening_timelist.rb', line 3

def opening_period
  @opening_period
end

Instance Method Details

#add_blankObject



15
16
17
# File 'app/models/eventable/opening_timelist.rb', line 15

def add_blank
  @items << @opening_period.opening_times.build
end

#errorsObject



11
12
13
# File 'app/models/eventable/opening_timelist.rb', line 11

def errors
  ActiveRecord::Errors.new(self)
end

#items_attributes=(attr) ⇒ Object



19
20
21
# File 'app/models/eventable/opening_timelist.rb', line 19

def items_attributes=(attr)
  @opening_period.opening_times_attributes=(attr)
end

#update_attributes(attrs) ⇒ Object



23
24
25
26
27
28
# File 'app/models/eventable/opening_timelist.rb', line 23

def update_attributes(attrs)
  attrs.each do |k,v|
    send "#{k}=", v
  end
  save
end