Class: Strict::Reader::Module

Inherits:
Module
  • Object
show all
Defined in:
lib/strict/reader/module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Module

Returns a new instance of Module.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/strict/reader/module.rb', line 8

def initialize(configuration)
  super()

  @configuration = configuration
  const_set(Strict::Attributes::Class::CONSTANT, configuration)
  configuration.attributes.each do |attribute|
    module_eval(
      "def #{attribute.name} = #{attribute.instance_variable}", # def name = @instance_variable
      __FILE__,
      __LINE__ - 2
    )
  end
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



6
7
8
# File 'lib/strict/reader/module.rb', line 6

def configuration
  @configuration
end

Instance Method Details

#inspectObject



22
23
24
# File 'lib/strict/reader/module.rb', line 22

def inspect
  "#<#{self.class} (#{configuration.attributes.map(&:name).join(', ')})>"
end