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
{{{
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ruby/riddl/client.rb', line 112 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)
}}}
126 127 128 |
# File 'lib/ruby/riddl/client.rb', line 126 def rpath @rpath end |
Instance Method Details
#delete(parameters = []) ⇒ Object
}}}
167 168 169 |
# File 'lib/ruby/riddl/client.rb', line 167 def delete(parameters = []) #{{{ exec_request('DELETE',parameters,false) end |
#get(parameters = []) ⇒ Object
}}}
146 147 148 |
# File 'lib/ruby/riddl/client.rb', line 146 def get(parameters = []) #{{{ exec_request('GET',parameters,false) end |
#post(parameters = []) ⇒ Object
}}}
153 154 155 |
# File 'lib/ruby/riddl/client.rb', line 153 def post(parameters = []) #{{{ exec_request('POST',parameters,false) end |
#put(parameters = []) ⇒ Object
}}}
160 161 162 |
# File 'lib/ruby/riddl/client.rb', line 160 def put(parameters = []) #{{{ exec_request('PUT',parameters,false) end |
#request(what) ⇒ Object
}}}
174 175 176 |
# File 'lib/ruby/riddl/client.rb', line 174 def request(what) #{{{ priv_request(what,false) end |
#simulate_delete(parameters = []) ⇒ Object
}}}
170 171 172 |
# File 'lib/ruby/riddl/client.rb', line 170 def simulate_delete(parameters = []) #{{{ exec_request('DELETE',parameters,true) end |
#simulate_get(parameters = []) ⇒ Object
}}}
149 150 151 |
# File 'lib/ruby/riddl/client.rb', line 149 def simulate_get(parameters = []) #{{{ exec_request('GET',parameters,true) end |
#simulate_post(parameters = []) ⇒ Object
}}}
156 157 158 |
# File 'lib/ruby/riddl/client.rb', line 156 def simulate_post(parameters = []) #{{{ exec_request('POST',parameters,true) end |
#simulate_put(parameters = []) ⇒ Object
}}}
163 164 165 |
# File 'lib/ruby/riddl/client.rb', line 163 def simulate_put(parameters = []) #{{{ exec_request('PUT',parameters,true) end |
#simulate_request(what) ⇒ Object
}}}
177 178 179 |
# File 'lib/ruby/riddl/client.rb', line 177 def simulate_request(what) #{{{ priv_request(what,true) end |
#ws(&blk) ⇒ Object
{{{
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/ruby/riddl/client.rb', line 128 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 |