class Fragments::Config
Contains a current config to request fragments properly
@author Sergey Gernyak
Attributes
Set or get a host to which request should be sent to get fragment's html structure
Specifies either fragments usage is enabled or not
Contains URL prefixes It should be a hash where:
-
key is a locale in ISO2 format
-
value is an URL prefix
Public Instance Methods
Setter for enableness flag @param value [Boolean] - A value of the flag @raise ArgumentError - when an invalid boolean value has been passed
# File lib/fragments/config.rb, line 36 def is_enabled=(value) raise ::ArgumentError, "Value should be a valid boolean one!" if !value.is_a?(TrueClass) && !value.is_a?(FalseClass) @is_enabled = value end
Provides an URI prefix for a given locale @param locale [String] - A locale for which URI prefix should be returned @return [String] an URI prefix
# File lib/fragments/config.rb, line 21 def uri_prefix(locale) uri_prefixes[normalize_key(locale)] || "" end
Setter for the URI prefixes mapping hash @param value [Hash] - A hash with URI prefix per locale mappings @raise ArgumentError - when an invalid value has been passed
# File lib/fragments/config.rb, line 28 def uri_prefixes=(value) raise ::ArgumentError, "Value should be a valid Hash!" unless value.is_a?(Hash) @uri_prefixes = Hash[value.map { |k, v| [normalize_key(k), v] }] end
Private Instance Methods
# File lib/fragments/config.rb, line 50 def normalize_key(value) value.downcase.to_sym end