Class: SportDb::Sync::Stage
- Inherits:
-
Object
- Object
- SportDb::Sync::Stage
- Defined in:
- lib/sportdb/readers/sync/more.rb
Class Method Summary collapse
Class Method Details
.find(name, event:) ⇒ Object
110 111 112 |
# File 'lib/sportdb/readers/sync/more.rb', line 110 def self.find( name, event: ) Model::Stage.find_by( name: name, event_id: event.id ) end |
.find!(name, event:) ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/sportdb/readers/sync/more.rb', line 113 def self.find!( name, event: ) rec = find( name, event: event ) if rec.nil? puts "** !!!ERROR!!! db sync - no stage match found for:" pp name pp event exit 1 end rec end |
.find_or_create(name, event:) ⇒ Object
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/sportdb/readers/sync/more.rb', line 124 def self.find_or_create( name, event: ) rec = find( name, event: event ) if rec.nil? attribs = { event_id: event.id, name: name, } rec = Model::Stage.create!( attribs ) end rec end |