Sha256: 2362729d7b0a07a70c33e0c80fa9c64ba6bb0a01a0f89848eff3de2c1148bf19

Contents?: true

Size: 929 Bytes

Versions: 22

Compression:

Stored size: 929 Bytes

Contents

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

22 entries across 22 versions & 1 rubygems

Version Path
alchemy_cms-3.6.7 app/models/alchemy/site/layout.rb
alchemy_cms-3.6.6 app/models/alchemy/site/layout.rb
alchemy_cms-3.6.5 app/models/alchemy/site/layout.rb
alchemy_cms-3.6.4 app/models/alchemy/site/layout.rb
alchemy_cms-3.6.3 app/models/alchemy/site/layout.rb
alchemy_cms-3.6.2 app/models/alchemy/site/layout.rb
alchemy_cms-3.6.1 app/models/alchemy/site/layout.rb
alchemy_cms-4.0.0.beta app/models/alchemy/site/layout.rb
alchemy_cms-3.6.0 app/models/alchemy/site/layout.rb
alchemy_cms-3.5.0 app/models/alchemy/site/layout.rb
alchemy_cms-3.4.2 app/models/alchemy/site/layout.rb
alchemy_cms-3.5.0.rc2 app/models/alchemy/site/layout.rb
alchemy_cms-3.5.0.rc1 app/models/alchemy/site/layout.rb
alchemy_cms-3.4.1 app/models/alchemy/site/layout.rb
alchemy_cms-3.3.3 app/models/alchemy/site/layout.rb
alchemy_cms-3.3.2 app/models/alchemy/site/layout.rb
alchemy_cms-3.4.0 app/models/alchemy/site/layout.rb
alchemy_cms-3.4.0.rc1 app/models/alchemy/site/layout.rb
alchemy_cms-3.3.1 app/models/alchemy/site/layout.rb
alchemy_cms-3.3.0 app/models/alchemy/site/layout.rb