Class: Stargate::Request::RowRequest

Inherits:
BasicRequest show all
Defined in:
lib/stargate/request/row_request.rb

Instance Attribute Summary collapse

Attributes inherited from BasicRequest

#path

Instance Method Summary collapse

Constructor Details

#initialize(table_name, name, timestamp = nil) ⇒ RowRequest

Returns a new instance of RowRequest.



8
9
10
11
12
# File 'lib/stargate/request/row_request.rb', line 8

def initialize(table_name, name, timestamp=nil)
  @table_name, @name, @timestamp = CGI.escape(table_name), CGI.escape(name), timestamp
  path = "/#{@table_name}/#{@name}"
  super(path)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/stargate/request/row_request.rb', line 5

def name
  @name
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



4
5
6
# File 'lib/stargate/request/row_request.rb', line 4

def table_name
  @table_name
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



6
7
8
# File 'lib/stargate/request/row_request.rb', line 6

def timestamp
  @timestamp
end

Instance Method Details

#create(columns = nil) ⇒ Object



21
22
23
24
25
# File 'lib/stargate/request/row_request.rb', line 21

def create(columns = nil)
  @path << (columns ? "/#{pack_params(columns)}" : "/")
  @path << "/#{@timestamp}" if @timestamp
  @path
end

#delete(columns = nil) ⇒ Object



27
28
29
30
31
# File 'lib/stargate/request/row_request.rb', line 27

def delete(columns = nil)
  @path << (columns ? "/#{pack_params(columns)}" : "/")
  @path << "/#{@timestamp}" if @timestamp
  @path
end

#show(columns = nil, options = { }) ⇒ Object



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

def show(columns = nil, options = { })
  @path << (columns ? "/#{pack_params(columns)}" : "/")
  @path << "/#{@timestamp}" if @timestamp
  @path << "?v=#{options[:version]}" if options[:version]
  @path
end