lib/gdshowsdb/models/song_occurence.rb in gdshowsdb-0.9.1 vs lib/gdshowsdb/models/song_occurence.rb in gdshowsdb-1.0.0

- old
+ new

@@ -3,7 +3,20 @@ belongs_to :show, :foreign_key => :show_uuid, :primary_key => :uuid belongs_to :song_ref, :foreign_key => :song_ref_uuid, :primary_key => :uuid, :counter_cache => true accepts_nested_attributes_for :show - attr_accessible :position, :uuid, :show + def self.create_from(spec) + occurence = SongOccurence.new + set_spec(occurence, spec) + occurence.save + occurence + end + + private + + def self.set_spec(occurence, spec) + occurence.uuid = spec[:uuid] + occurence.position = spec[:position] + occurence.show = ShowSet.find_by_uuid(spec[:show_set_uuid]).show + end end \ No newline at end of file