Module: Isomorfeus::Data::GenericClassApi

Defined in:
lib/isomorfeus/data/generic_class_api.rb

Instance Method Summary collapse

Instance Method Details

#create(key: nil, **things) ⇒ Object



110
111
112
# File 'lib/isomorfeus/data/generic_class_api.rb', line 110

def create(key: nil, **things)
  new(key: key, **things).create
end

#current_userObject



118
119
120
# File 'lib/isomorfeus/data/generic_class_api.rb', line 118

def current_user
  Isomorfeus.current_user
end

#destroy(key:) ⇒ Object

RUBY_ENGINE



57
58
59
60
# File 'lib/isomorfeus/data/generic_class_api.rb', line 57

def destroy(key:)
  promise_destroy(key: key)
  true
end

#execute_create(&block) ⇒ Object

execute



52
# File 'lib/isomorfeus/data/generic_class_api.rb', line 52

def execute_create(_); end

#execute_destroy(&block) ⇒ Object



53
# File 'lib/isomorfeus/data/generic_class_api.rb', line 53

def execute_destroy(_); end

#execute_load(&block) ⇒ Object



54
# File 'lib/isomorfeus/data/generic_class_api.rb', line 54

def execute_load(_); end

#execute_save(&block) ⇒ Object



55
# File 'lib/isomorfeus/data/generic_class_api.rb', line 55

def execute_save(_); end

#gen_ref_s(key) ⇒ Object

RUBY_ENGINE



102
103
104
# File 'lib/isomorfeus/data/generic_class_api.rb', line 102

def gen_ref_s(key)
  "---iso-object-reference---#{self.name}---#{key}---"
end

#gen_sid_s(key) ⇒ Object



106
107
108
# File 'lib/isomorfeus/data/generic_class_api.rb', line 106

def gen_sid_s(key)
  "[#{self.name}|#{key}]"
end

#load(key:, _already_loaded: {}) ⇒ Object Also known as: load!



19
20
21
22
23
# File 'lib/isomorfeus/data/generic_class_api.rb', line 19

def load(key:)
  instance = self.new(key: key, _loading: true)
  promise_load(key: key, instance: instance) unless instance.loaded?
  instance
end

#promise_create(key: nil, **things) ⇒ Object



114
115
116
# File 'lib/isomorfeus/data/generic_class_api.rb', line 114

def promise_create(key: nil, **things)
  new(key: key, **things).promise_create
end

#promise_destroy(key:) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/isomorfeus/data/generic_class_api.rb', line 10

def promise_destroy(key:)
  Isomorfeus::Transport.promise_send_path( 'Isomorfeus::Data::Handler::Generic', self.name, :destroy, key: key).then do |agent|
    agent.process do
      Isomorfeus.store.dispatch(type: 'DATA_DESTROY', data: [self.name, key])
      true
    end
  end
end

#promise_load(key:) ⇒ Object Also known as: promise_load!



25
26
27
28
29
30
31
32
# File 'lib/isomorfeus/data/generic_class_api.rb', line 25

def promise_load(key:, instance: nil)
  instance = self.new(key: key, _loading: true) unless instance
  if instance.loaded?
    Promise.new.resolve(instance)
  else
    promise_load!(key: key, instance: instance)
  end
end

#pub_sub_clientObject



122
123
124
# File 'lib/isomorfeus/data/generic_class_api.rb', line 122

def pub_sub_client
  Isomorfeus.pub_sub_client
end