Class: Strict::Attributes::Configuration

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/strict/attributes/configuration.rb

Defined Under Namespace

Classes: UnknownAttributeError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes:) ⇒ Configuration

Returns a new instance of Configuration.



32
33
34
35
# File 'lib/strict/attributes/configuration.rb', line 32

def initialize(attributes:)
  @attributes = attributes
  @attributes_index = attributes.to_h { |a| [a.name, a] }
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



30
31
32
# File 'lib/strict/attributes/configuration.rb', line 30

def attributes
  @attributes
end

Instance Method Details

#named!(name) ⇒ Object



37
38
39
# File 'lib/strict/attributes/configuration.rb', line 37

def named!(name)
  attributes_index.fetch(name) { raise UnknownAttributeError.new(attribute_name: name) }
end