11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/adva/belongs_to_author.rb', line 11
def belongs_to_user(*args)
options = args.
args = (args.empty? ? [:user] : args)
belongs_to_cacheable *args.dup << options
args.each do |name|
class_eval <<-code, __FILE__, __LINE__
def #{name}_ip
#{name}.ip if #{name} && #{name}.respond_to?(:ip)
end
def #{name}_agent
#{name}.agent if #{name} && #{name}.respond_to?(:agent)
end
def #{name}_referer
#{name}.referer if #{name} && #{name}.respond_to?(:referer)
end
def #{name}_link include_email: true
if include_email
%(<a href="mailto:\#{#{name}_email}">\#{#{name}_name}</a>).html_safe
else
#{name}_name
end
end
code
end
end
|