Class: Workarea::Metadata
- Inherits:
-
Object
- Object
- Workarea::Metadata
show all
- Defined in:
- app/queries/workarea/metadata.rb
Defined Under Namespace
Classes: CatalogCategory, ContentPage, HomePage
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(content) ⇒ Metadata
Returns a new instance of Metadata.
23
24
25
26
|
# File 'app/queries/workarea/metadata.rb', line 23
def initialize(content)
@content = content
@model = content.contentable
end
|
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
3
4
5
|
# File 'app/queries/workarea/metadata.rb', line 3
def content
@content
end
|
#model ⇒ Object
Returns the value of attribute model.
3
4
5
|
# File 'app/queries/workarea/metadata.rb', line 3
def model
@model
end
|
Class Method Details
.automation_klass(model) ⇒ Object
9
10
11
12
13
|
# File 'app/queries/workarea/metadata.rb', line 9
def self.automation_klass(model)
"Workarea::Metadata::#{model_name(model.class).classify}".constantize
rescue NameError
nil
end
|
.model_name(klass) ⇒ Object
5
6
7
|
# File 'app/queries/workarea/metadata.rb', line 5
def self.model_name(klass)
ActiveModel::Naming.param_key(klass)
end
|
.update(content) ⇒ Object
15
16
17
18
19
20
21
|
# File 'app/queries/workarea/metadata.rb', line 15
def self.update(content)
contentable = content.contentable
return unless contentable.present?
metadata_klass = automation_klass(contentable)
metadata_klass.new(content).update if metadata_klass.present?
end
|
Instance Method Details
#description ⇒ Object
43
44
45
46
47
48
|
# File 'app/queries/workarea/metadata.rb', line 43
def description
raise(
NotImplementedError,
"#{self.class.name} must implement the #description method"
)
end
|
#title ⇒ Object
36
37
38
39
40
41
|
# File 'app/queries/workarea/metadata.rb', line 36
def title
raise(
NotImplementedError,
"#{self.class.name} must implement the #title method"
)
end
|
#update ⇒ Object
28
29
30
31
32
33
34
|
# File 'app/queries/workarea/metadata.rb', line 28
def update
return unless content.automate_metadata?
content.browser_title = title
content.meta_description = description
content.save!
end
|