50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/interview/option_attribute.rb', line 50
def get_options(object)
options = []
general_defaults = object.class.lookup_ancestors.map do |klass|
"#{object.class.i18n_scope}.options.#{klass.model_name.i18n_key}.#{method}"
end
if object.class.const_defined? "#{@method.upcase}_OPTIONS"
opts = object.class.const_get("#{@method.upcase}_OPTIONS")
elsif object.class.respond_to? :descendants and
(klass = object.class.descendants.find { |c| c.const_defined? "#{@method.upcase}_OPTIONS" })
opts = klass.const_get("#{@method.upcase}_OPTIONS")
end
if opts
opts.map do |option|
defaults = general_defaults.map do |default|
:"#{default}.#{option}"
end
options << [h.t(defaults.shift, default: defaults), option]
end
end
return options
end
|