Class: Locomotive::Wagon::SiteDecorator

Inherits:
Steam::Decorators::I18nDecorator
  • Object
show all
Includes:
PersistAssetsConcern, ToHashConcern
Defined in:
lib/locomotive/wagon/decorators/site_decorator.rb

Direct Known Subclasses

UpdateSiteDecorator

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PersistAssetsConcern

#asset_io, #replace_with_content_assets!, #replace_with_content_assets_in_hash!

Methods included from ToHashConcern

#prepare_value_for_hash, #to_hash

Constructor Details

#initialize(object, locale = nil, base_path = nil, content_assets_pusher = nil) ⇒ SiteDecorator

Returns a new instance of SiteDecorator.



11
12
13
14
15
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 11

def initialize(object, locale = nil, base_path = nil, content_assets_pusher = nil)
  self.__base_path__ = base_path
  self.__content_assets_pusher__ = content_assets_pusher
  super(object, locale || object.default_locale, nil)
end

Instance Attribute Details

#__base_path__Object

Returns the value of attribute base_path.



9
10
11
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 9

def __base_path__
  @__base_path__
end

#__content_assets_pusher__Object

Returns the value of attribute content_assets_pusher.



9
10
11
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 9

def __content_assets_pusher__
  @__content_assets_pusher__
end

Instance Method Details

#__attributes__Object



65
66
67
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 65

def __attributes__
  %i(name handle robots_txt locales timezone seo_title meta_keywords meta_description picture metafields_schema metafields metafields_ui asset_host sections_content routes overwrite_same_content_assets allow_dots_in_slugs)
end

#allow_dots_in_slugsObject



55
56
57
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 55

def allow_dots_in_slugs
  self[:allow_dots_in_slugs]
end

#domainsObject



17
18
19
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 17

def domains
  (__getobj__.domains || []) - ['localhost']
end

#metafieldsObject



29
30
31
32
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 29

def metafields
  replace_with_content_assets_in_hash!(self[:metafields])
  self[:metafields]&.to_json
end

#metafields_schemaObject



25
26
27
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 25

def metafields_schema
  self[:metafields_schema].try(:to_json)
end

#metafields_uiObject



21
22
23
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 21

def metafields_ui
  self[:metafields_ui].try(:to_json)
end

#overwrite_same_content_assetsObject



51
52
53
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 51

def overwrite_same_content_assets
  self[:overwrite_same_content_assets]
end

#pictureObject



42
43
44
45
46
47
48
49
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 42

def picture
  picture_path = __getobj__.picture
  if picture_path && File.exist?(picture_path)
    Locomotive::Coal::UploadIO.new(picture_path, nil, 'icon.png')
  else
    nil
  end
end

#routesObject



38
39
40
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 38

def routes
  self[:routes]&.to_json
end

#sections_contentObject



34
35
36
# File 'lib/locomotive/wagon/decorators/site_decorator.rb', line 34

def sections_content
  replace_with_content_assets!(super&.to_json)
end