Class: WorldDb::Models::Region
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- WorldDb::Models::Region
- Defined in:
- lib/worlddb/models/region.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.create_from_ary!(regions, more_values = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/worlddb/models/region.rb', line 27 def self.create_from_ary!( regions, more_values={} ) regions.each do |values| ## key & title & country required attr = { key: values[0], title: values[1] } attr = attr.merge( more_values ) ## check for optional values values[2..-1].each do |value| if value.is_a? Country attr[ :country_id ] = value.id else # issue warning: unknown type for value end end Region.create!( attr ) end # each region end |
Instance Method Details
#title_w_synonyms ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/worlddb/models/region.rb', line 16 def title_w_synonyms return title if synonyms.blank? buf = '' buf << title buf << ' | ' buf << synonyms.split('|').join(' | ') buf end |