Class: SongRef

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Includes:
Extensions::UUID
Defined in:
lib/gdshowsdb/models/song_ref.rb

Class Method Summary collapse

Class Method Details

.create_from(spec) ⇒ Object



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

def self.create_from(spec)
  song_ref = SongRef.new
  set_spec(song_ref, spec)
  song_ref.save    
end

.remove_from(spec) ⇒ Object



27
28
29
# File 'lib/gdshowsdb/models/song_ref.rb', line 27

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

.set_spec(song_ref, spec) ⇒ Object



33
34
35
36
37
38
# File 'lib/gdshowsdb/models/song_ref.rb', line 33

def self.set_spec(song_ref, spec)
  song_ref.uuid = spec[:uuid]
  song_ref.name = spec[:name]
  song_ref.slug = spec[:name].parameterize.underscore
  song_ref
end

.update_from(spec) ⇒ Object



21
22
23
24
25
# File 'lib/gdshowsdb/models/song_ref.rb', line 21

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