Sha256: b153013fc71cd38dcec5b1a04c5cd39569bbee90e505841bfd9a07e233025974
Contents?: true
Size: 1.1 KB
Versions: 11
Compression:
Stored size: 1.1 KB
Contents
module LucidSimpleOperation module Mixin def self.included(base) base.extend(LucidPropDeclaration::Mixin) base.extend(Isomorfeus::Operation::GenericClassApi) if RUBY_ENGINE == 'opal' base.instance_exec do def op end end else Isomorfeus.add_valid_operation_class(base) unless base == LucidSimpleOperation::Base base.instance_exec do def op(&block) @op = block end end end end attr_reader :props def initialize(**props_hash) props_hash = self.class.validated_props(props_hash) @props = LucidProps.new(props_hash) end def promise_run original_promise = Promise.new operation = self promise = original_promise.then do |_| operation.instance_exec(&operation.class.instance_variable_get(:@op)) end original_promise.resolve promise end def current_user Isomorfeus.current_user end def pub_sub_client Isomorfeus.pub_sub_client end end end
Version data entries
11 entries across 11 versions & 1 rubygems