Module: LucidSimpleOperation::Mixin
- Defined in:
- lib/isomorfeus_operation/lucid_simple_operation/mixin.rb
Instance Attribute Summary collapse
-
#props ⇒ Object
readonly
Returns the value of attribute props.
Class Method Summary collapse
Instance Method Summary collapse
- #current_user ⇒ Object
- #initialize(**props_hash) ⇒ Object
- #promise_run ⇒ Object
- #pub_sub_client ⇒ Object
Instance Attribute Details
#props ⇒ Object (readonly)
Returns the value of attribute props.
23 24 25 |
# File 'lib/isomorfeus_operation/lucid_simple_operation/mixin.rb', line 23 def props @props end |
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/isomorfeus_operation/lucid_simple_operation/mixin.rb', line 3 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 |
Instance Method Details
#current_user ⇒ Object
42 43 44 |
# File 'lib/isomorfeus_operation/lucid_simple_operation/mixin.rb', line 42 def current_user Isomorfeus.current_user end |
#initialize(**props_hash) ⇒ Object
25 26 27 28 |
# File 'lib/isomorfeus_operation/lucid_simple_operation/mixin.rb', line 25 def initialize(**props_hash) props_hash = self.class.validated_props(props_hash) @props = LucidProps.new(props_hash) end |
#promise_run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/isomorfeus_operation/lucid_simple_operation/mixin.rb', line 30 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 |
#pub_sub_client ⇒ Object
46 47 48 |
# File 'lib/isomorfeus_operation/lucid_simple_operation/mixin.rb', line 46 def pub_sub_client Isomorfeus.pub_sub_client end |