class Agave::Local::Site

Attributes

entity[R]

Public Class Methods

new(entity, items_repo) click to toggle source
# File lib/agave/local/site.rb, line 16
def initialize(entity, items_repo)
  @entity = entity
  @items_repo = items_repo
end

Public Instance Methods

favicon() click to toggle source
# File lib/agave/local/site.rb, line 29
def favicon
  read_attribute(:favicon, FieldType::File, false)
end
favicon_meta_tags(theme_color = nil) click to toggle source
# File lib/agave/local/site.rb, line 38
def favicon_meta_tags(theme_color = nil)
  Utils::FaviconTagsBuilder.new(self, theme_color).meta_tags
end
global_seo() click to toggle source
# File lib/agave/local/site.rb, line 21
def global_seo
  read_attribute(:global_seo, FieldType::GlobalSeo, locales.size > 1)
end
inspect()
Alias for: to_s
theme() click to toggle source
# File lib/agave/local/site.rb, line 25
def theme
  read_attribute(:theme, FieldType::Theme, false)
end
to_hash() click to toggle source
# File lib/agave/local/site.rb, line 42
def to_hash
  attributes = [
    :id, :name, :locales, :theme, :domain,
    :no_index, :global_seo, :favicon, :production_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_s() click to toggle source
# File lib/agave/local/site.rb, line 33
def to_s
  "#<Site id=#{id} site_name=#{name}>"
end
Also aliased as: inspect

Private Instance Methods

read_attribute(method, type_klass, localized) click to toggle source
# File lib/agave/local/site.rb, line 60
def read_attribute(method, type_klass, localized)
  value = if localized
            obj = entity.send(method) || {}

            Utils::LocaleValue.find(obj)
          else
            entity.send(method)
          end

  type_klass.parse(value, @items_repo)
end