Class: Dato::Local::FieldType::GlobalSeo

Inherits:
Object
  • Object
show all
Defined in:
lib/dato/local/field_type/global_seo.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site_name, title_suffix, twitter_account, facebook_page_url, fallback_seo, repo) ⇒ GlobalSeo

Returns a new instance of GlobalSeo.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dato/local/field_type/global_seo.rb', line 22

def initialize(
  site_name,
  title_suffix,
  ,
  facebook_page_url,
  fallback_seo,
  repo
)
  @site_name = site_name
  @title_suffix = title_suffix
  @twitter_account = 
  @facebook_page_url = facebook_page_url
  @fallback_seo = fallback_seo
  @repo = repo
end

Instance Attribute Details

#facebook_page_urlObject (readonly)

Returns the value of attribute facebook_page_url.



9
10
11
# File 'lib/dato/local/field_type/global_seo.rb', line 9

def facebook_page_url
  @facebook_page_url
end

#site_nameObject (readonly)

Returns the value of attribute site_name.



9
10
11
# File 'lib/dato/local/field_type/global_seo.rb', line 9

def site_name
  @site_name
end

#title_suffixObject (readonly)

Returns the value of attribute title_suffix.



9
10
11
# File 'lib/dato/local/field_type/global_seo.rb', line 9

def title_suffix
  @title_suffix
end

#twitter_accountObject (readonly)

Returns the value of attribute twitter_account.



9
10
11
# File 'lib/dato/local/field_type/global_seo.rb', line 9

def 
  @twitter_account
end

Class Method Details

.parse(value, repo) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/dato/local/field_type/global_seo.rb', line 11

def self.parse(value, repo)
  value && new(
    value[:site_name],
    value[:title_suffix],
    value[:twitter_account],
    value[:facebook_page_url],
    value[:fallback_seo],
    repo,
  )
end

Instance Method Details

#fallback_seoObject



38
39
40
# File 'lib/dato/local/field_type/global_seo.rb', line 38

def fallback_seo
  @fallback_seo && Seo.parse(@fallback_seo, @repo)
end

#to_hash(*args) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/dato/local/field_type/global_seo.rb', line 42

def to_hash(*args)
  {
    site_name: site_name,
    title_suffix: title_suffix,
    twitter_account: ,
    facebook_page_url: facebook_page_url,
    fallback_seo: fallback_seo && fallback_seo.to_hash(*args),
  }
end