lib/tracksperanto/block_init.rb in tracksperanto-3.5.9 vs lib/tracksperanto/block_init.rb in tracksperanto-4.0.0
- old
+ new
@@ -1,9 +1,7 @@
-# -*- encoding : utf-8 -*-
# Implements the conventional constructor with "hash of attributes" and block support
module Tracksperanto::BlockInit
- def initialize(object_attribute_hash = {})
- m = method(respond_to?(:public_send) ? :public_send : :send)
- object_attribute_hash.map { |(k, v)| m.call("#{k}=", v) }
+ def initialize(**object_attribute_hash)
+ object_attribute_hash.map { |(k, v)| public_send("#{k}=", v) }
yield(self) if block_given?
end
end