Class: Sidemash::Sdk::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/sidemash/sdk/hook.rb

Direct Known Subclasses

HookHttpCall, HookWsCall, HookZoom

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(h) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/sidemash/sdk/hook.rb', line 59

def self.from_hash(h)
  case h['_type']
    when HookHttpCall._type then HookHttpCall.from_hash(h)
    when HookWsCall._type then HookWsCall.from_hash(h)
    else raise(ArgumentError, "Invalid hash submitted for creating 'Hook'" + " Unexpected '_type' = " + ty)
  end
end

.from_json(js) ⇒ Object



38
39
40
41
# File 'lib/sidemash/sdk/hook.rb', line 38

def self.from_json(js)
  h = JSON.parse(js)
  Hook.from_hash(h)
end

.from_remote(h) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/sidemash/sdk/hook.rb', line 51

def self.from_remote(h)
  case h['_type']
    when HookHttpCall._type then HookHttpCall.from_remote(h)
    when HookWsCall._type then HookWsCall.from_remote(h)
    else raise(ArgumentError, "Invalid hash submitted for creating 'Hook'" + " Unexpected '_type' = " + ty)
  end
end

Instance Method Details

#http_call?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/sidemash/sdk/hook.rb', line 22

def http_call?
  @_type == HttpCall._type
end

#not_http_call?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/sidemash/sdk/hook.rb', line 30

def not_http_call?
  @_type != HttpCall._type
end

#not_ws_call?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/sidemash/sdk/hook.rb', line 34

def not_ws_call?
  @_type != WsCall._type
end

#to_hashObject

Raises:

  • (NotImplementedError)


47
48
49
# File 'lib/sidemash/sdk/hook.rb', line 47

def to_hash
  raise NotImplementedError, 'The implementation lies in the children classes HttpCall, WsCall' 
end

#to_json(*a) ⇒ Object



67
68
69
# File 'lib/sidemash/sdk/hook.rb', line 67

def to_json(*a)
  to_hash.to_json(*a)
end

#to_remoteObject

Raises:

  • (NotImplementedError)


43
44
45
# File 'lib/sidemash/sdk/hook.rb', line 43

def to_remote
  raise NotImplementedError, 'The implementation lies in the children classes HttpCall, WsCall' 
end

#ws_call?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/sidemash/sdk/hook.rb', line 26

def ws_call?
  @_type == WsCall._type
end