Sha256: 1df4fe82adf955e6cbd50432d81a08b946ac3370508a1e5573db27f8ab7aebe4

Contents?: true

Size: 868 Bytes

Versions: 2

Compression:

Stored size: 868 Bytes

Contents

# encoding: utf-8

module Loaf
  class 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

    # Setup this configuration
    #
    # @api public
    def initialize
      VALID_ATTRIBUTES.each do |attr|
        send("#{attr}=", self.class.const_get("DEFAULT_#{attr.to_s.upcase}"))
      end
    end

    # Convert all properties into hash
    #
    # @return [Hash]
    #
    # @api public
    def to_hash
      VALID_ATTRIBUTES.reduce({}) { |acc, k| acc[k] = send(k); acc }
    end
  end # Configuration
end # Loaf

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loaf-0.5.0 lib/loaf/configuration.rb
loaf-0.4.0 lib/loaf/configuration.rb