Module: MusixMatch::Models::ModelBuilder
- Defined in:
- lib/musix_match/models/model.rb
Class Method Summary collapse
Class Method Details
.build_constructor(base, *attributes) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/musix_match/models/model.rb', line 34 def self.build_constructor(base, *attributes) initialize_method = Proc.new do |*params| model_params = params.first || {} attributes.each do |attribute| instance_variable_set("@#{attribute}", model_params[attribute.to_s]) end end base.send(:define_method, :initialize, &initialize_method) end |