Class: Lazier::Configuration
- Inherits:
-
Hashie::Dash
- Object
- Hashie::Dash
- Lazier::Configuration
- Includes:
- I18n
- Defined in:
- lib/lazier/configuration.rb
Overview
A configuration class to set properties.
Instance Attribute Summary
Attributes included from I18n
#i18n_locale, #i18n_locales_path, #i18n_root
Class Method Summary (collapse)
-
+ (Object) property(property_name, options = {})
Defines a property on the configuration.
Instance Method Summary (collapse)
-
- (Configuration) initialize(attributes = {}, &block)
constructor
Initializes a new configuration object.
Methods included from I18n
Constructor Details
- (Configuration) initialize(attributes = {}, &block)
Initializes a new configuration object.
15 16 17 18 19 |
# File 'lib/lazier/configuration.rb', line 15 def initialize(attributes = {}, &block) @lazier_i18n = Lazier::Localizer.new(:lazier, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../../locales/")).i18n i18n_setup(:lazier, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../../locales/")) super(attributes, &block) end |
Class Method Details
+ (Object) property(property_name, options = {})
Defines a property on the configuration. Options are as follows:
- :default - Specify a default value for this property.
- :required - Specify the value as required for this property, to raise an error if a value is unset in a new or existing configuration.
- :readonly - Specify if the property is readonly, which means that it can only defined during creation of the configuration.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/lazier/configuration.rb', line 30 def self.property(property_name, = {}) super(property_name, ) if [:readonly] then class_eval <<-ACCESSOR def #{property_name}=(_) raise ArgumentError.new(@lazier_i18n.configuration.readonly("#{property_name}", "#{name}")) end ACCESSOR end end |