Class: Para::SeoTools::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Para::SeoTools::Page
show all
- Defined in:
- app/models/para/seo_tools/page.rb
Constant Summary
collapse
- META_TAGS =
:title, :description, :keywords, :image, :canonical
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
127
128
129
130
131
132
133
|
# File 'app/models/para/seo_tools/page.rb', line 127
def method_missing(method_name, *args, &block)
if config.key?(method_name.to_s)
config[method_name.to_s]
else
super
end
end
|
Instance Method Details
#default(name) ⇒ Object
34
35
36
|
# File 'app/models/para/seo_tools/page.rb', line 34
def default(name)
process(name, defaults[name.to_s]) if defaults[name.to_s]
end
|
#defaults ⇒ Object
26
27
28
29
30
31
32
|
# File 'app/models/para/seo_tools/page.rb', line 26
def defaults
if (hash = read_attribute(:defaults))
hash
else
self.defaults = {}
end
end
|
#host ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'app/models/para/seo_tools/page.rb', line 76
def host
host = []
if Para::SeoTools.handle_subdomain
if (subdomain = config['subdomain'])
host << subdomain
else
host << Para::SeoTools.default_domain
end
end
if Para::SeoTools.handle_domain
host << config['domain']
else
host << Para::SeoTools.host
end
host = host.compact.join('.')
[Para::SeoTools.protocol, host].join('://')
end
|
18
19
20
21
22
23
24
|
# File 'app/models/para/seo_tools/page.rb', line 18
def meta_tag(name)
if (value = send(name).presence) && (meta = process(name, value)).present?
return meta
end
default(name)
end
|
#scope_attributes ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'app/models/para/seo_tools/page.rb', line 62
def scope_attributes
scope.each_with_object({}) do |attribute, hash|
hash[attribute] = if self.class.column_names.include?(attribute.to_s)
send(attribute)
else
config[attribute.to_s]
end
end
end
|
#siblings ⇒ Object
98
99
100
|
# File 'app/models/para/seo_tools/page.rb', line 98
def siblings
self.class.where(identifier: identifier).where.not(id: id)
end
|
#url ⇒ Object
72
73
74
|
# File 'app/models/para/seo_tools/page.rb', line 72
def url
@url ||= [host, path].join
end
|