Class: RiderServer::Request

Inherits:
Object show all
Defined in:
lib/rider_server/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(operation) ⇒ Request

Returns a new instance of Request.



14
15
16
17
18
19
# File 'lib/rider_server/request.rb', line 14

def initialize(operation)
  raise "Operation ID cannot be nil" if operation["id"].nil?
  raise "Operation name cannot be nil" if operation["op"].nil?

  @data = operation
end

Instance Method Details

#[](name) ⇒ Object



45
46
47
# File 'lib/rider_server/request.rb', line 45

def [](name)
  @data[name]
end

#[]=(name, value) ⇒ Object



49
50
51
# File 'lib/rider_server/request.rb', line 49

def []=(name, value)
  @data[name] = value
end

#fetch(*args) ⇒ Object



37
38
39
# File 'lib/rider_server/request.rb', line 37

def fetch(*args)
  @data.fetch(*args)
end

#idObject



25
26
27
# File 'lib/rider_server/request.rb', line 25

def id
  @data["id"]
end

#inspectObject



53
54
55
# File 'lib/rider_server/request.rb', line 53

def inspect
  "#<RiderServer::Request:#{object_id} id=#{id} session=#{session} op=#{op}}>"
end

#key?(name) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/rider_server/request.rb', line 41

def key?(name)
  @data.key? name
end

#opObject



21
22
23
# File 'lib/rider_server/request.rb', line 21

def op
  @data["op"]
end

#sessionObject



29
30
31
# File 'lib/rider_server/request.rb', line 29

def session
  @data["session"]
end

#set(key, value) ⇒ Object



33
34
35
# File 'lib/rider_server/request.rb', line 33

def set(key, value)
  @data[key] = value
end

#to_hObject



57
58
59
# File 'lib/rider_server/request.rb', line 57

def to_h
  @data
end