Class: Locomotive::Steam::Site
- Inherits:
-
Object
- Object
- Locomotive::Steam::Site
- Includes:
- Models::Entity
- Defined in:
- lib/locomotive/steam/entities/site.rb
Instance Attribute Summary
Attributes included from Models::Entity
#associations, #attributes, #base_url, #localized_attributes
Instance Method Summary collapse
- #default_locale ⇒ Object
- #handle ⇒ Object
-
#initialize(attributes = {}) ⇒ Site
constructor
A new instance of Site.
- #last_modified_at ⇒ Object
- #locales ⇒ Object
- #timezone ⇒ Object
- #timezone_name ⇒ Object
- #to_liquid ⇒ Object
Methods included from Models::Entity
#[], #[]=, #_id, #change, #method_missing, #respond_to?, #serialize
Methods included from Models::Concerns::ToJson
Methods included from Models::Concerns::Validation
Constructor Details
#initialize(attributes = {}) ⇒ Site
Returns a new instance of Site.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/locomotive/steam/entities/site.rb', line 7 def initialize(attributes = {}) super({ cache_enabled: false, cache_control: nil, cache_vary: nil, bypass_browser_locale: 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, sections: nil, sections_content: nil, asset_host: nil, routes: [] }.merge(attributes)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Locomotive::Steam::Models::Entity
Instance Method Details
#default_locale ⇒ Object
36 37 38 |
# File 'lib/locomotive/steam/entities/site.rb', line 36 def default_locale locales.first || :en end |
#handle ⇒ Object
32 33 34 |
# File 'lib/locomotive/steam/entities/site.rb', line 32 def handle self[:handle] || self[:subdomain] end |
#last_modified_at ⇒ Object
52 53 54 |
# File 'lib/locomotive/steam/entities/site.rb', line 52 def last_modified_at [self.content_version, self.template_version].compact.sort.last || self.updated_at end |
#locales ⇒ Object
40 41 42 |
# File 'lib/locomotive/steam/entities/site.rb', line 40 def locales (self[:locales] || [:en]).map(&:to_sym) end |
#timezone ⇒ Object
48 49 50 |
# File 'lib/locomotive/steam/entities/site.rb', line 48 def timezone @timezone ||= ActiveSupport::TimeZone.new(timezone_name) end |
#timezone_name ⇒ Object
44 45 46 |
# File 'lib/locomotive/steam/entities/site.rb', line 44 def timezone_name self[:timezone] || self[:timezone_name] || 'UTC' end |