Class: Dato::Local::Site

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/dato/local/site.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity, items_repo) ⇒ Site

Returns a new instance of Site.



16
17
18
19
# File 'lib/dato/local/site.rb', line 16

def initialize(entity, items_repo)
  @entity = entity
  @items_repo = items_repo
end

Instance Attribute Details

#entityObject (readonly)

Returns the value of attribute entity.



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

def entity
  @entity
end

Instance Method Details

#faviconObject



29
30
31
# File 'lib/dato/local/site.rb', line 29

def favicon
  read_attribute(:favicon, FieldType::UploadId, false)
end

#favicon_meta_tags(theme_color = nil) ⇒ Object



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

def favicon_meta_tags(theme_color = nil)
  Utils::FaviconTagsBuilder.new(self, theme_color).meta_tags
end

#global_seoObject



21
22
23
# File 'lib/dato/local/site.rb', line 21

def global_seo
  read_attribute(:global_seo, FieldType::GlobalSeo, locales.size > 1)
end

#themeObject



25
26
27
# File 'lib/dato/local/site.rb', line 25

def theme
  read_attribute(:theme, FieldType::Theme, false)
end

#to_hashObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/dato/local/site.rb', line 42

def to_hash
  attributes = %i[
    id name locales theme domain internal_domain
    no_index global_seo favicon frontend_url
  ]

  attributes.each_with_object({}) do |attribute, result|
    value = send(attribute)
    result[attribute] = if value.respond_to?(:to_hash)
                          value.to_hash
                        else
                          value
                        end
  end
end

#to_sObject Also known as: inspect



33
34
35
# File 'lib/dato/local/site.rb', line 33

def to_s
  "#<Site id=#{id} site_name=#{name}>"
end