Module: Vident::TypedComponent

Extended by:
ActiveSupport::Concern
Defined in:
lib/vident/typed_component.rb,
lib/vident/typed_component.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



43
44
45
# File 'lib/vident/typed_component.rb', line 43

def self.included(base)
  raise "Vident::TypedComponent requires dry-struct to be installed"
end

Instance Method Details

#initialize(attrs = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/vident/typed_component.rb', line 28

def initialize(attrs = {})
  before_initialise(attrs)
  prepare_attributes(attrs)
  # The attributes need to also be set as ivars
  attributes.each do |attr_name, attr_value|
    instance_variable_set(self.class.attribute_ivar_names[attr_name], attr_value)
  end
  after_initialise
  super()
end