Sha256: 2659b187b806262b2a5dfed69095597e0bd69d7263403ef33f17d5713f40586a

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

module Pageflow
  class Theming < ActiveRecord::Base
    belongs_to :account
    has_many :widgets, as: :subject

    has_many :entries

    scope :with_home_url, -> { where.not(home_url: '') }
    scope :for_request, ->(request) { Pageflow.config.theming_request_scope.call(all, request) }

    validates :account, :presence => true
    validates_inclusion_of :theme_name, :in => ->(_) { Pageflow.config.themes.names }

    def resolve_widgets(options = {})
      widgets.resolve(Pageflow.config_for(account), options)
    end

    def cname_domain
      cname.split('.').pop(2).join('.')
    end

    def theme
      Pageflow.config.themes.get(theme_name)
    end

    def name
      I18n.t('pageflow.admin.themings.name', :account_name => account.name, :theme_name => theme_name)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pageflow-0.10.0 app/models/pageflow/theming.rb