Module: Kangaru::Attributable

Extended by:
Concern
Included in:
Configurator, Database
Defined in:
lib/kangaru/concerns/attributable.rb

Instance Method Summary collapse

Methods included from Concern

append_features, class_methods, included

Instance Method Details

#initialize(**attributes) ⇒ Object



21
22
23
24
25
# File 'lib/kangaru/concerns/attributable.rb', line 21

def initialize(**attributes)
  attributes = self.class.defaults.merge(**attributes)

  merge!(**attributes)
end

#merge!(**attributes) ⇒ Object



27
28
29
30
31
# File 'lib/kangaru/concerns/attributable.rb', line 27

def merge!(**attributes)
  attributes.slice(*self.class.attributes).each do |attr, value|
    instance_variable_set(:"@#{attr}", value)
  end
end