Completed
Push — master ( ee3653...30ef8d )
by
unknown
02:04 queued 32s
created

Category   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find_or_create_defaults() 0 6 1
A i18n_key() 0 3 1
1
class Category < ActiveRecord::Base
2
  has_many :categorizations
3
  has_many :sessions, :through => :categorizations
4
5
  def self.find_or_create_defaults
6
    cnf = YAML.load_file(File.join(Rails.root, 'config', 'categories.yml'))
7
    cnf.each do |key, val|
8
      Category.where(id: key).first_or_initialize.update(name: val)
9
    end
10
  end
11
12
  def i18n_key
13
    name.gsub(/&/, '').gsub(/\s+/, '_').downcase
14
  end
15
16
end
17