Class: Qwester::Answer

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/qwester/answer.rb

Constant Summary collapse

DEFAULT_VALUE =
'Not applicable'
STANDARD_VALUES =
['Yes', 'No', DEFAULT_VALUE]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_valueObject



35
36
37
# File 'app/models/qwester/answer.rb', line 35

def self.default_value
  DEFAULT_VALUE
end

.find_first_or_create(attributes) ⇒ Object



27
28
29
# File 'app/models/qwester/answer.rb', line 27

def self.find_first_or_create(attributes)
  where(attributes).first || create(attributes)
end

.remove_weighting_aliasObject



61
62
63
64
65
66
# File 'app/models/qwester/answer.rb', line 61

def self.remove_weighting_alias
  if weighting_alias
    remove_method weighting_alias.to_sym
    @weighting_alias = nil
  end
end

.rule_label_prefixObject



39
40
41
# File 'app/models/qwester/answer.rb', line 39

def self.rule_label_prefix
  @rule_label_prefix ||= 'a'
end

.standard_valuesObject



31
32
33
# File 'app/models/qwester/answer.rb', line 31

def self.standard_values
  STANDARD_VALUES
end

.weighting_aliasObject



43
44
45
# File 'app/models/qwester/answer.rb', line 43

def self.weighting_alias
  @weighting_alias
end

.weighting_alias=(name) ⇒ Object



47
48
49
50
51
52
53
54
# File 'app/models/qwester/answer.rb', line 47

def self.weighting_alias=(name)
  if name
    @weighting_alias = name
    define_method(name.to_sym) {send(:weighting)}
  else
    remove_weighting_alias
  end
end

.weighting_alias_nameObject



56
57
58
59
# File 'app/models/qwester/answer.rb', line 56

def self.weighting_alias_name
  name = weighting_alias || :weighting
  name.to_s
end

Instance Method Details

#rule_labelObject



68
69
70
# File 'app/models/qwester/answer.rb', line 68

def rule_label
  "#{self.class.rule_label_prefix}#{self.id}"
end