Sha256: 944423f69826b6d772a79d23ad6510f6c2a5401f015f5e2a0bb235e7b7cf8a55
Contents?: true
Size: 549 Bytes
Versions: 7
Compression:
Stored size: 549 Bytes
Contents
require 'casting/client' module Casting class InvalidClientError < StandardError; end def self.delegating(assignments) assignments.each do |object, mod| cast_object(object, mod) end yield ensure assignments.each do |object, mod| uncast_object(object) end end def self.cast_object(object, mod) raise InvalidClientError.new unless object.respond_to?(:cast_as) object.cast_as(mod) end def self.uncast_object(object) return unless object.respond_to?(:uncast) object.uncast end end
Version data entries
7 entries across 7 versions & 1 rubygems