Class: Locomotive::Site
- Inherits:
-
Object
- Object
- Locomotive::Site
- Includes:
- Concerns::Shared::Seo, Concerns::Site::AccessPoints, Concerns::Site::Cache, Concerns::Site::Locales, Concerns::Site::Metafields, Concerns::Site::PrivateAccess, Concerns::Site::Routes, Concerns::Site::Sections, Concerns::Site::Timezone, Concerns::Site::UrlRedirections, Mongoid::Document
- Defined in:
- app/models/locomotive/site.rb
Instance Method Summary collapse
- #accounts ⇒ Object
- #admin_memberships ⇒ Object
-
#created_by ⇒ Object
associations ##.
- #is_admin?(account) ⇒ Boolean
- #localized_content_types ⇒ Object
- #membership_for(account) ⇒ Object
-
#memberships ⇒ Object
behaviours ##.
-
#name ⇒ Object
validations ##.
-
#ordered_pages(conditions = {}) ⇒ Criteria
Get all the pages in the right order: depth and position, both ASC.
- #to_liquid ⇒ Object
- #to_steam ⇒ Object
Methods included from Concerns::Site::Metafields
#any_localized_metafield?, #cast_metafields, #find_metafield, #has_metafields?
Methods included from Concerns::Site::UrlRedirections
#add_or_update_url_redirection, #remove_url_redirection, #url_redirections=, #url_redirections_plain_text, #url_redirections_with_information
Methods included from Concerns::Site::Cache
Methods included from Concerns::Site::Timezone
Methods included from Concerns::Site::Locales
#default_locale, #default_locale_was, #each_locale, #is_default_locale?, #locale_fallbacks, #locales=, #localized?, #prefix_default_locale?, #with_default_locale
Methods included from Concerns::Site::AccessPoints
#asset_host=, #domains=, #handle=, #main_domain, #to_param
Instance Method Details
#accounts ⇒ Object
66 67 68 |
# File 'app/models/locomotive/site.rb', line 66 def accounts Account.criteria.in(_id: self.memberships.map(&:account_id)) end |
#admin_memberships ⇒ Object
74 75 76 |
# File 'app/models/locomotive/site.rb', line 74 def admin_memberships self.memberships.find_all { |m| m.admin? } end |
#created_by ⇒ Object
associations ##
28 |
# File 'app/models/locomotive/site.rb', line 28 belongs_to :created_by, class_name: 'Locomotive::Account', optional: true |
#is_admin?(account) ⇒ Boolean
78 79 80 |
# File 'app/models/locomotive/site.rb', line 78 def is_admin?(account) self.memberships.detect { |m| m.admin? && m.account_id == account._id } end |
#localized_content_types ⇒ Object
62 63 64 |
# File 'app/models/locomotive/site.rb', line 62 def localized_content_types self.content_types.localized end |
#membership_for(account) ⇒ Object
70 71 72 |
# File 'app/models/locomotive/site.rb', line 70 def membership_for(account) self.memberships.where(account_id: account._id).first end |
#memberships ⇒ Object
behaviours ##
48 |
# File 'app/models/locomotive/site.rb', line 48 accepts_nested_attributes_for :memberships, allow_destroy: true |
#name ⇒ Object
validations ##
19 |
# File 'app/models/locomotive/site.rb', line 19 field :name |
#ordered_pages(conditions = {}) ⇒ Criteria
Get all the pages in the right order: depth and position, both ASC.
58 59 60 |
# File 'app/models/locomotive/site.rb', line 58 def ordered_pages(conditions = {}) self.pages.unscoped.where(conditions || {}).order_by_depth_and_position end |
#to_liquid ⇒ Object
87 88 89 |
# File 'app/models/locomotive/site.rb', line 87 def to_liquid to_steam.to_liquid end |
#to_steam ⇒ Object
82 83 84 85 |
# File 'app/models/locomotive/site.rb', line 82 def to_steam repository = Locomotive::Steam::Services.build_instance.repositories.site repository.build(self.attributes.dup) end |