10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/dyn_meta/action_controller.rb', line 10
def meta(name, val = nil)
in_name = "@meta_#{name}"
return instance_variable_set(in_name, val) if val.present?
return instance_variable_get(in_name) if instance_variable_get(in_name)
trans = I18n.translate("meta")[name.to_s.pluralize] || {}
hash = trans
[:controller, :action, :id].each do |p|
val = params[p] && hash[params[p].to_s.to_sym] || nil
if val.nil?
return instance_variable_set(in_name, hash[:default] || trans[:default] || nil)
elsif val.is_a?(Hash)
hash = val
else
return instance_variable_set(in_name, val)
end
end
end
|