Sha256: 7fea0271a47ab0eeb25dd13a1f77626bdfb5141510781c0697f0717af9718ce8
Contents?: true
Size: 1.24 KB
Versions: 12
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true # Copyright (c) 2016 Andy Pike - The MIT license # # This file has been copied from https://github.com/andypike/rectify/blob/master/lib/rectify/command.rb # We have done this so we can decouple Decidim from any Virtus dependency, which is a dead project # Please follow Decidim discussion to understand more https://github.com/decidim/decidim/discussions/7234 module Decidim class Command include ::Wisper::Publisher def self.call(*args, **kwargs, &block) event_recorder = Decidim::EventRecorder.new command = new(*args, **kwargs) command.subscribe(event_recorder) command.evaluate(&block) if block_given? command.call event_recorder.events end def evaluate(&block) @caller = eval("self", block.binding, __FILE__, __LINE__) instance_eval(&block) end def transaction(&block) ActiveRecord::Base.transaction(&block) if block_given? end def method_missing(method_name, ...) if @caller.respond_to?(method_name, true) @caller.send(method_name, ...) else super end end def respond_to_missing?(method_name, include_private = false) @caller.respond_to?(method_name, include_private) end end end
Version data entries
12 entries across 12 versions & 1 rubygems