Class: Pakyow::Data::Result

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/pakyow/data/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, proxy, originating_method: nil, originating_args: []) ⇒ Result

Returns a new instance of Result.



11
12
13
14
15
16
# File 'lib/pakyow/data/result.rb', line 11

def initialize(result, proxy, originating_method: nil, originating_args: [])
  @__proxy = proxy
  @originating_method = originating_method
  @originating_args = originating_args
  __setobj__(result)
end

Instance Attribute Details

#__proxyObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/pakyow/data/result.rb', line 9

def __proxy
  @__proxy
end

Instance Method Details

#marshal_dumpObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pakyow/data/result.rb', line 22

def marshal_dump
  {
    proxy: {
      app: @__proxy.app,
      source: @__proxy.source.source_name,
      proxied_calls: @__proxy.proxied_calls
    },

    originating_method: @originating_method,
    originating_args: @originating_args
  }
end

#marshal_load(state) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pakyow/data/result.rb', line 35

def marshal_load(state)
  result = state[:proxy][:app].data.public_send(
    state[:proxy][:source]
  ).apply(
    state[:proxy][:proxied_calls]
  )

  if state[:originating_method]
    result = result.public_send(state[:originating_method], *state[:originating_args])
  end

  __setobj__(result)
end

#nil?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/pakyow/data/result.rb', line 18

def nil?
  __getobj__.nil?
end

#pp(*args) ⇒ Object

Fixes an issue using pp inside a delegator.



51
52
53
# File 'lib/pakyow/data/result.rb', line 51

def pp(*args)
  Kernel.pp(*args)
end