Class: Riddl::Client::Resource
- Inherits:
-
Object
- Object
- Riddl::Client::Resource
- Defined in:
- lib/ruby/riddl/client.rb
Overview
}}}
Instance Attribute Summary collapse
-
#rpath ⇒ Object
readonly
}}}.
Instance Method Summary collapse
-
#delete(parameters = []) ⇒ Object
}}}.
-
#get(parameters = []) ⇒ Object
}}}.
-
#initialize(base, wrapper, path, options) ⇒ Resource
constructor
{{{.
-
#post(parameters = []) ⇒ Object
}}}.
-
#put(parameters = []) ⇒ Object
}}}.
-
#request(what) ⇒ Object
}}}.
-
#simulate_delete(parameters = []) ⇒ Object
}}}.
-
#simulate_get(parameters = []) ⇒ Object
}}}.
-
#simulate_post(parameters = []) ⇒ Object
}}}.
-
#simulate_put(parameters = []) ⇒ Object
}}}.
-
#simulate_request(what) ⇒ Object
}}}.
-
#ws(&blk) ⇒ Object
{{{.
Constructor Details
#initialize(base, wrapper, path, options) ⇒ Resource
{{{
159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/ruby/riddl/client.rb', line 159 def initialize(base,wrapper,path,) #{{{ @base = base @wrapper = wrapper @rpath = "/#{path}".gsub(/\/+/,'/') @options = @path = if @wrapper.nil? @rpath else @path = @wrapper.paths.find{ |e| e[1] =~ @rpath } raise PathError, 'Path not found.' if @path.nil? @path[0] end @rpath = @rpath == '/' ? '' : @rpath end |
Instance Attribute Details
#rpath ⇒ Object (readonly)
}}}
173 174 175 |
# File 'lib/ruby/riddl/client.rb', line 173 def rpath @rpath end |
Instance Method Details
#delete(parameters = []) ⇒ Object
}}}
214 215 216 |
# File 'lib/ruby/riddl/client.rb', line 214 def delete(parameters = []) #{{{ exec_request('DELETE',parameters,false) end |
#get(parameters = []) ⇒ Object
}}}
193 194 195 |
# File 'lib/ruby/riddl/client.rb', line 193 def get(parameters = []) #{{{ exec_request('GET',parameters,false) end |
#post(parameters = []) ⇒ Object
}}}
200 201 202 |
# File 'lib/ruby/riddl/client.rb', line 200 def post(parameters = []) #{{{ exec_request('POST',parameters,false) end |
#put(parameters = []) ⇒ Object
}}}
207 208 209 |
# File 'lib/ruby/riddl/client.rb', line 207 def put(parameters = []) #{{{ exec_request('PUT',parameters,false) end |
#request(what) ⇒ Object
}}}
221 222 223 |
# File 'lib/ruby/riddl/client.rb', line 221 def request(what) #{{{ priv_request(what,false) end |
#simulate_delete(parameters = []) ⇒ Object
}}}
217 218 219 |
# File 'lib/ruby/riddl/client.rb', line 217 def simulate_delete(parameters = []) #{{{ exec_request('DELETE',parameters,true) end |
#simulate_get(parameters = []) ⇒ Object
}}}
196 197 198 |
# File 'lib/ruby/riddl/client.rb', line 196 def simulate_get(parameters = []) #{{{ exec_request('GET',parameters,true) end |
#simulate_post(parameters = []) ⇒ Object
}}}
203 204 205 |
# File 'lib/ruby/riddl/client.rb', line 203 def simulate_post(parameters = []) #{{{ exec_request('POST',parameters,true) end |
#simulate_put(parameters = []) ⇒ Object
}}}
210 211 212 |
# File 'lib/ruby/riddl/client.rb', line 210 def simulate_put(parameters = []) #{{{ exec_request('PUT',parameters,true) end |
#simulate_request(what) ⇒ Object
}}}
224 225 226 |
# File 'lib/ruby/riddl/client.rb', line 224 def simulate_request(what) #{{{ priv_request(what,true) end |
#ws(&blk) ⇒ Object
{{{
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/ruby/riddl/client.rb', line 175 def ws(&blk) #{{{ EM.run do conn = EventMachine::WebSocketClient.connect((@base + @rpath).sub(/^http/,'ws')) conn.disconnect do EM::stop_event_loop end if @options[:debug] conn.errback do |e| @options[:debug].puts "WS ERROR: #{e}" end end blk.call(conn) end end |