Sha256: e936fb072851a13932fe43b26b2ba551e1c9ae9e5f0adb33a2f733efe3adec38

Contents?: true

Size: 960 Bytes

Versions: 17

Compression:

Stored size: 960 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  module Site::Layout
    extend ActiveSupport::Concern
    SITE_DEFINITIONS_FILE = Rails.root.join("config/alchemy/site_layouts.yml")

    module ClassMethods
      # Returns the site layouts definition defined in +site_layouts.yml+ file
      #
      def definitions
        @definitions ||= read_site_definitions
      end

      private

      # Reads the site layouts definition file named +site_layouts.yml+ in +config/alchemy/+
      #
      # It returns empty Array if no file is present
      #
      def read_site_definitions
        YAML.load_file(SITE_DEFINITIONS_FILE) || []
      rescue Errno::ENOENT
        []
      end
    end

    # Returns site's layout definition
    #
    def definition
      self.class.definitions.detect { |l| l["name"] == partial_name }
    end

    # Returns the name for the layout partial
    #
    def partial_name
      name.parameterize.underscore
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
alchemy_cms-5.0.10 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.9 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.8 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.7 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.6 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.5 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.4 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.3 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.2 app/models/alchemy/site/layout.rb
alchemy_cms-5.1.0.beta2 app/models/alchemy/site/layout.rb
alchemy_cms-5.1.0.beta1 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.1 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.0 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.0.rc2 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.0.rc1 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.0.beta2 app/models/alchemy/site/layout.rb
alchemy_cms-5.0.0.beta1 app/models/alchemy/site/layout.rb