Module: Orchestrator::Service::Mixin

Includes:
Core::Mixin
Defined in:
lib/orchestrator/service/mixin.rb

Instance Method Summary collapse

Methods included from Core::Mixin

#[], #[]=, #__STATS__, #current_user, #define_setting, #logger, #schedule, #setting, #subscribe, #systems, #task, #thread, #unsubscribe, #wake_device

Instance Method Details

#clear_cookiesObject



47
48
49
# File 'lib/orchestrator/service/mixin.rb', line 47

def clear_cookies
    # TODO::
end

#config(options) ⇒ Object



35
36
37
38
39
# File 'lib/orchestrator/service/mixin.rb', line 35

def config(options)
    @__config__.thread.schedule do
        @__config__.processor.config = options
    end
end

#defaults(options) ⇒ Object



41
42
43
44
45
# File 'lib/orchestrator/service/mixin.rb', line 41

def defaults(options)
    @__config__.thread.schedule do
        @__config__.processor.send_options(options)
    end
end

#delete(path, options = {}, &blk) ⇒ Object



31
32
33
# File 'lib/orchestrator/service/mixin.rb', line 31

def delete(path, options = {}, &blk)
    request(:delete, path, options, &blk)
end

#get(path, options = {}, &blk) ⇒ Object



19
20
21
# File 'lib/orchestrator/service/mixin.rb', line 19

def get(path, options = {}, &blk)
    request(:get, path, options, &blk)
end

#post(path, options = {}, &blk) ⇒ Object



23
24
25
# File 'lib/orchestrator/service/mixin.rb', line 23

def post(path, options = {}, &blk)
    request(:post, path, options, &blk)
end

#put(path, options = {}, &blk) ⇒ Object



27
28
29
# File 'lib/orchestrator/service/mixin.rb', line 27

def put(path, options = {}, &blk)
    request(:put, path, options, &blk)
end

#request(method, path, options = {}, &blk) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/orchestrator/service/mixin.rb', line 6

def request(method, path, options = {}, &blk)
    defer = @__config__.thread.defer
    options[:method] = method
    options[:path] = path
    options[:defer] = defer
    options[:max_waits] = 0  # HTTP will only ever respond to a request
    options[:on_receive] = blk if blk     # on command success
    @__config__.thread.schedule do
        @__config__.processor.queue_command(options)
    end
    defer.promise
end

#use_middleware(klass) ⇒ Object



51
52
53
# File 'lib/orchestrator/service/mixin.rb', line 51

def use_middleware(klass)
    # TODO::
end