Class: Sinatra::JsonRpc::Request

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serializers::JSON, ActiveModel::Validations
Defined in:
lib/sinatra/json_rpc/request.rb

Constant Summary collapse

REQUEST_ERROR =
Sinatra::JsonRpc::RequestError

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id.



13
14
15
# File 'lib/sinatra/json_rpc/request.rb', line 13

def id
  @id
end

#jsonrpcObject

Returns the value of attribute jsonrpc.



13
14
15
# File 'lib/sinatra/json_rpc/request.rb', line 13

def jsonrpc
  @jsonrpc
end

#methodObject

Returns the value of attribute method.



13
14
15
# File 'lib/sinatra/json_rpc/request.rb', line 13

def method
  @method
end

#paramsObject

Returns the value of attribute params.



13
14
15
# File 'lib/sinatra/json_rpc/request.rb', line 13

def params
  @params
end

Instance Method Details

#attributesObject



28
29
30
31
32
33
34
35
# File 'lib/sinatra/json_rpc/request.rb', line 28

def attributes
  {
    'jsonrpc' => "2.0",
    'method' => nil,
    'params' => nil,
    'id' => nil
  }
end

#attributes=(hash) ⇒ Object



21
22
23
24
25
26
# File 'lib/sinatra/json_rpc/request.rb', line 21

def attributes=(hash)
  hash.each do |key, value|
    raise Sinatra::JsonRpc::RequestError unless respond_to? key
    instance_variable_set("@#{key}", value)
  end
end