Sha256: 3e678a0ca703a267c2985569d3d81a01cc37cd9f23de95a287a2fe606712c1d9

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

# encoding: utf-8

module Loaf
  module Configuration

    VALID_ATTRIBUTES = [
      :locales_path,
      :style_classes,
      :crumb_length,
      :last_crumb_linked,
      :capitalize,
      :root
    ]

    attr_accessor *VALID_ATTRIBUTES

    DEFAULT_LOCALES_PATH = "/"

    DEFAULT_STYLE_CLASSES = 'selected'

    DEFAULT_CRUMB_LENGTH = 30

    DEFAULT_LAST_CRUMB_LINKED = false

    DEFAULT_CAPITALIZE = false

    DEFAULT_ROOT = true

    # Sets the Loaf configuration options. Best used by passing a block.
    #
    # Loaf.configure do |config|
    #   config.capitalize = true
    # end
    def configure
      yield self
    end

    def self.extended(base)
      base.setup(self)
    end

    def config
      VALID_ATTRIBUTES.inject({}) { |hash, k| hash[k] = send(k); hash }
    end

    def setup(parent)
      VALID_ATTRIBUTES.each do |attr|
        send("#{attr}=", parent.const_get("DEFAULT_#{attr.to_s.upcase}"))
      end
    end

  end # Configuration
end # Loaf

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
loaf-0.3.0 lib/loaf/configuration.rb