Class: Lazier::Configuration
- Inherits:
-
Hashie::Dash
- Object
- Hashie::Dash
- Lazier::Configuration
- Defined in:
- lib/lazier/configuration.rb
Overview
A configuration class to set properties.
Class Method Summary (collapse)
-
+ (Object) property(name, options = {})
Defines a property on the configuration.
Instance Method Summary (collapse)
-
- (Configuration) initialize(attributes = {}, &block)
constructor
Initializes a new configuration object.
Constructor Details
- (Configuration) initialize(attributes = {}, &block)
Initializes a new configuration object.
12 13 14 15 |
# File 'lib/lazier/configuration.rb', line 12 def initialize(attributes = {}, &block) @i18n = Lazier::I18n.instance super(attributes, &block) end |
Class Method Details
+ (Object) 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.
26 27 28 29 30 31 32 33 34 |
# File 'lib/lazier/configuration.rb', line 26 def self.property(name, = {}) super(name, ) if [:readonly] send(:define_method, "#{name}=") do |_| assert_readonly_property!(name) end end end |