Class: Locomotive::Steam::Site
- Inherits:
-
Object
- Object
- Locomotive::Steam::Site
show all
- Includes:
- Models::Entity
- Defined in:
- lib/locomotive/steam/entities/site.rb
Instance Attribute Summary
#associations, #attributes, #base_url, #localized_attributes
Instance Method Summary
collapse
#[], #[]=, #_id, #change, #method_missing, #respond_to?, #serialize
#as_json, #to_hash, #to_json
#errors, #valid?
Constructor Details
#initialize(attributes = {}) ⇒ Site
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/locomotive/steam/entities/site.rb', line 7
def initialize(attributes = {})
super({
cache_enabled: false,
prefix_default_locale: false,
updated_at: nil,
content_version: nil,
template_version: nil,
domains: [],
redirect_to_first_domain: false,
redirect_to_https: false,
url_redirections: [],
private_access: false,
password: nil,
metafields_schema: {},
metafields: nil
}.merge(attributes))
end
|
Instance Method Details
#default_locale ⇒ Object
29
30
31
|
# File 'lib/locomotive/steam/entities/site.rb', line 29
def default_locale
locales.first || :en
end
|
#handle ⇒ Object
25
26
27
|
# File 'lib/locomotive/steam/entities/site.rb', line 25
def handle
self[:handle] || self[:subdomain]
end
|
#last_modified_at ⇒ Object
45
46
47
|
# File 'lib/locomotive/steam/entities/site.rb', line 45
def last_modified_at
[self.content_version, self.template_version].compact.sort.last || self.updated_at
end
|
#locales ⇒ Object
33
34
35
|
# File 'lib/locomotive/steam/entities/site.rb', line 33
def locales
(self[:locales] || [:en]).map(&:to_sym)
end
|
#timezone ⇒ Object
41
42
43
|
# File 'lib/locomotive/steam/entities/site.rb', line 41
def timezone
@timezone ||= ActiveSupport::TimeZone.new(timezone_name)
end
|
#timezone_name ⇒ Object
37
38
39
|
# File 'lib/locomotive/steam/entities/site.rb', line 37
def timezone_name
self[:timezone] || self[:timezone_name] || 'UTC'
end
|
#to_liquid ⇒ Object
49
50
51
|
# File 'lib/locomotive/steam/entities/site.rb', line 49
def to_liquid
Locomotive::Steam::Liquid::Drops::Site.new(self)
end
|