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
115
116
117
118
119
120
121
|
# File 'app/models/para/seo_tools/page.rb', line 115
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'app/models/para/seo_tools/page.rb', line 70
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.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
56
57
58
59
60
61
62
63
64
|
# File 'app/models/para/seo_tools/page.rb', line 56
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
92
93
94
|
# File 'app/models/para/seo_tools/page.rb', line 92
def siblings
self.class.where(identifier: identifier).where.not(id: id)
end
|
#url ⇒ Object
66
67
68
|
# File 'app/models/para/seo_tools/page.rb', line 66
def url
@url ||= [host, path].join
end
|