| Class | Param |
| In: |
app/models/param.rb
|
| Parent: | ActiveRecord::Base |
false if param exists and value is ‘f’, otherwise true
# File app/models/param.rb, line 57
57: def boolean(name)
58: (p = first(:conditions => { :name => name })) ? p.value != 'f' : true
59: end
# File app/models/param.rb, line 48
48: def comment_flags_for_suspend
49: Param.value_named(COMMENT_FLAGS_FOR_SUSPEND, Default::COMMENT_FLAGS_FOR_SUSPEND).to_i
50: end
# File app/models/param.rb, line 17
17: def create_for_code(code, value)
18: create(:name => LOGIN_REQUIRED[code.to_sym] || code, :value => value)
19: end
# File app/models/param.rb, line 96
96: def data_load(name)
97: record = first(:conditions => { :name => name })
98: (record && YAML.load(record.value)) || []
99: end
# File app/models/param.rb, line 87
87: def data_store(name, value)
88: record = first(:conditions => { :name => name })
89: if record
90: record.update_attribute(:value, YAML.dump(value))
91: else
92: create(:name => name, :value => value)
93: end
94: end
# File app/models/param.rb, line 25
25: def english_vary_percent
26: p = first(:conditions => { :name => ENGLISH_VARY_PERCENT })
27: p ? 100 - p.value.to_f : 0
28: end
# File app/models/param.rb, line 30
30: def english_vary_prob
31: english_vary_percent / 100.0
32: end
# File app/models/param.rb, line 13
13: def find_by_code(code)
14: first(:conditions => { :name => LOGIN_REQUIRED[code.to_sym] || code })
15: end
# File app/models/param.rb, line 65
65: def flag_question_image?
66: boolean(FLAG_QUESTION_IMAGE)
67: end
# File app/models/param.rb, line 52
52: def item_flags_for_suspend
53: Param.value_named(ITEM_FLAGS_FOR_SUSPEND, Default::ITEM_FLAGS_FOR_SUSPEND).to_i
54: end
# File app/models/param.rb, line 69
69: def lock_spawn_fetch(visit_id)
70: lock_spawn(Spawn::FETCH, visit_id)
71: end
# File app/models/param.rb, line 9
9: def login_required?(page)
10: boolean(LOGIN_REQUIRED[page])
11: end
# File app/models/param.rb, line 21
21: def random_first_question?
22: boolean(RANDOM_FIRST_QUESTION)
23: end
store as integer equal to a rounded (float * 100)
# File app/models/param.rb, line 35
35: def random_new_question_percent
36: p = first(:conditions => { :name => RANDOM_NEW_QUESTION_PERCENT })
37: 100 - (p && p.value).to_f
38: end
# File app/models/param.rb, line 44
44: def random_new_question_prob
45: random_new_question_percent / 100.0
46: end
# File app/models/param.rb, line 40
40: def refresh_question_after
41: value_named(REFRESH_QUESTION_AFTER, Default::REFRESH_QUESTION_AFTER).to_i
42: end
# File app/models/param.rb, line 77
77: def unlock_spawn_fetch(visit_id)
78: unlock_spawn(Spawn::FETCH, visit_id)
79: end
# File app/models/param.rb, line 73
73: def unlocked_spawn_fetch?(visit_id)
74: unlocked_spawn?(Spawn::FETCH, visit_id)
75: end
# File app/models/param.rb, line 83
83: def unlocked_spawn_graphs?; unlocked_spawn?(Spawn::GRAPH) end