Sha256: 56c2f3adc08ce7434493268234d3d3937cfbe1209c4ff7e45190a8783a14c5bd
Contents?: true
Size: 614 Bytes
Versions: 1
Compression:
Stored size: 614 Bytes
Contents
module Ownership module GlobalMethods def owner(owner, &block) raise ArgumentError, "Missing block" unless block_given? previous_value = Thread.current[:ownership_owner] begin Thread.current[:ownership_owner] = owner begin # callbacks if Ownership.around_change Ownership.around_change.call(owner, block) else block.call end rescue Exception => e e.owner = owner raise end ensure Thread.current[:ownership_owner] = previous_value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ownership-0.1.0 | lib/ownership/global_methods.rb |