Created
September 8, 2020 11:09
-
-
Save RStankov/28eddd727ce122538272b1b158ddaff8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SEO | |
def self.for(record) | |
"::SEO::#{record.class_name}".safe_constantize.new(record) | |
end | |
end | |
class SEO::Base | |
attr_reader :record | |
def initialize(record) | |
@record = record | |
end | |
def title | |
raise NotImplementedError | |
end | |
def descrion | |
raise NotImplementedError | |
end | |
end | |
class SEO::Post | |
def title | |
post.title | |
end | |
def description | |
post.tagline | |
end | |
end | |
class SEO::User | |
#.... | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SEO | |
def self.for(record) | |
"::SEO::#{record.class_name}".safe_constantize.call(record) | |
end | |
end | |
class SEO::Tags | |
attr_reader :title, :descrion | |
def initialize(title:, description:) | |
@title = title | |
@description = description | |
end | |
end | |
module SEO::Post | |
def self.call(post) | |
Tags.new(title: post.title, description: post.tagline) | |
end | |
end | |
class SEO::User | |
#.... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment