Class: ShowSet

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Extensions::UUID
Defined in:
lib/gdshowsdb/models/show_set.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_from(spec) ⇒ Object



8
9
10
11
12
13
# File 'lib/gdshowsdb/models/show_set.rb', line 8

def self.create_from(spec)
  show_set = ShowSet.new
  set_spec(show_set, spec)
  show_set.save
  show_set
end

.encore?(sets, set) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
# File 'lib/gdshowsdb/models/show_set.rb', line 30

def self.encore?(sets, set)
  return false unless sets
  last = (sets.size - 1) == sets.index(set)
  song_size = set[:songs].size          
  song_size < 3 && last
end

.find_all_by_year(year) ⇒ Object



26
27
28
# File 'lib/gdshowsdb/models/show_set.rb', line 26

def self.find_all_by_year(year)
  ShowSet.joins(:show).where('shows.year = ?', year)
end

.remove_from(spec) ⇒ Object



22
23
24
# File 'lib/gdshowsdb/models/show_set.rb', line 22

def self.remove_from(spec)
  ShowSet.find_by_uuid(spec[:uuid]).delete
end

.set_spec(show_set, spec) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/gdshowsdb/models/show_set.rb', line 43

def self.set_spec(show_set, spec)
  show_set.uuid = spec[:uuid]
  show_set.show_uuid = spec[:show_uuid]
  show_set.position = spec[:position]
  show_set.encore = spec[:encore]
  show_set.show = Show.find_by_uuid(spec[:show_uuid])
end

.update_from(spec) ⇒ Object



15
16
17
18
19
20
# File 'lib/gdshowsdb/models/show_set.rb', line 15

def self.update_from(spec)
  show_set = ShowSet.find_by_uuid(spec[:uuid])
  set_spec(show_set, spec)
  show_set.save
  show_set
end

Instance Method Details

#encore?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/gdshowsdb/models/show_set.rb', line 37

def encore?
  encore
end