Sha256: 664ebe2f99cf29c87a0ee702fbf8c1ec5a63775986a7b503b01d726f05b5ee76

Contents?: true

Size: 882 Bytes

Versions: 5

Compression:

Stored size: 882 Bytes

Contents

class LucidOperation
  extend Preact::PropDeclarationMixin
  extend Isomorfeus::Operation::GenericClassApi
  include LucidI18nMixin

  class << self
    if RUBY_ENGINE == 'opal'
      def op; end
    else
      def inherited(base)
        Isomorfeus.add_valid_operation_class(base)
      end

      def op(&block)
        @op = block
      end
    end
  end

  attr_reader :props

  def initialize(**props_hash)
    @props = self.class.validated_props(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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
isomorfeus-operation-23.9.0.rc12 lib/lucid_operation.rb
isomorfeus-operation-23.9.0.rc11 lib/lucid_operation.rb
isomorfeus-operation-23.9.0.rc10 lib/lucid_operation.rb
isomorfeus-operation-23.9.0.rc9 lib/lucid_operation.rb
isomorfeus-operation-23.9.0.rc8 lib/lucid_operation.rb