Module: Kagu::AttributesInitializer

Included in:
Playlist, Track
Defined in:
lib/kagu/attributes_initializer.rb

Instance Method Summary collapse

Instance Method Details

#initialize(attributes = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/kagu/attributes_initializer.rb', line 5

def initialize(attributes = {})
  attributes.each do |name, value|
    send("#{name}=", value) if respond_to?("#{name}=", true)
  end
  self.class.const_get(:MANDATORY_ATTRIBUTES).each do |attribute|
    raise Error.new("#{self.class}##{attribute} is mandatory for #{inspect}") if send(attribute).nil?
  end
end