Sha256: 2da60b79a6a541f102d3993622196ec48ad3daf4714650ea3286e99433571306
Contents?: true
Size: 710 Bytes
Versions: 10
Compression:
Stored size: 710 Bytes
Contents
# frozen_string_literal: true module Coactive module Contextualizer extend ActiveSupport::Concern def contextualize self.class._contexts.each do |var| instance_variable_set("@#{var.name}", @context[var.name]) define_singleton_method var.name do instance_variable_get("@#{var.name}") end end return_value = yield if block_given? self.class._contexts.each do |var| if var.output_return? @context[var.name] = return_value elsif var.output? && instance_variable_defined?("@#{var.name}") @context[var.name] = instance_variable_get("@#{var.name}") end end return_value end end end
Version data entries
10 entries across 10 versions & 1 rubygems