Sha256: 41d11b63a2fb3587938bfd07c6c816cc79664c6e6b7ab945a64c86733407061f
Contents?: true
Size: 770 Bytes
Versions: 26
Compression:
Stored size: 770 Bytes
Contents
module MotionPrime module HasNormalizer def normalize_options(unordered_options, receiver = nil, order = nil) options = if order Hash[unordered_options.sort_by { |k,v| order.index(k.to_s).to_i }] else unordered_options end options.each do |key, option| unordered_options[key] = normalize_object(option, receiver) end end def normalize_object(object, receiver = nil) receiver ||= self if object.is_a?(Proc) receiver.send(:instance_exec, self, &object) elsif object.is_a?(Hash) object.inject({}) do |result, (key, nested_object)| result.merge(key => normalize_object(nested_object, receiver)) end else object end end end end
Version data entries
26 entries across 26 versions & 1 rubygems