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.



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

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.



12
13
14
# File 'lib/dato/local/field_type/global_seo.rb', line 12

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.



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

def title_suffix
  @title_suffix
end

#twitter_accountObject (readonly)

Returns the value of attribute twitter_account.



11
12
13
# File 'lib/dato/local/field_type/global_seo.rb', line 11

def 
  @twitter_account
end

Class Method Details

.parse(value, repo) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/dato/local/field_type/global_seo.rb', line 14

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



41
42
43
# File 'lib/dato/local/field_type/global_seo.rb', line 41

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

#to_hash(*args) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/dato/local/field_type/global_seo.rb', line 45

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