class Lazier::Configuration

A configuration class to set properties.

Public Class Methods

new(attributes = {}, &block) click to toggle source

Initializes a new configuration object. @see Hash#initialize

@param attributes [Hash] The initial values of properties of this configuration. @param block [Proc] A block to use for default values.

Calls superclass method
# File lib/lazier/configuration.rb, line 14
def initialize(attributes = {}, &block)
  @i18n = Lazier::I18n.instance
  super(attributes, &block)
end
property(name, options = {}) click to toggle source

@param name [String|Symbol] The new property name. @param options [Hash] The options for the property. @option options [Boolean] :default Specify a default value for this property. @option options [Boolean] :required Set the value as required for this property, this will raise an error if the value is unset when creating or editing. @option options [Boolean] :readonly Specify if the property is readonly, which means that it can only defined during creation of the configuration.

Calls superclass method
# File lib/lazier/configuration.rb, line 26
def self.property(name, options = {})
  super(name, options)

  if options[:readonly]
    send(:define_method, "#{name}=") do |_|
      assert_readonly_property!(name)
    end
  end
end