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
{{{.
-
#patch(parameters = []) ⇒ Object
}}}.
-
#post(parameters = []) ⇒ Object
}}}.
-
#put(parameters = []) ⇒ Object
}}}.
-
#request(what) ⇒ Object
}}}.
-
#simulate_delete(parameters = []) ⇒ Object
}}}.
-
#simulate_get(parameters = []) ⇒ Object
}}}.
-
#simulate_patch(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
{{{
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/ruby/riddl/client.rb', line 136 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)
}}}
150 151 152 |
# File 'lib/ruby/riddl/client.rb', line 150 def rpath @rpath end |
Instance Method Details
#delete(parameters = []) ⇒ Object
}}}
194 195 196 |
# File 'lib/ruby/riddl/client.rb', line 194 def delete(parameters = []) #{{{ exec_request('DELETE',parameters,false) end |
#get(parameters = []) ⇒ Object
}}}
166 167 168 |
# File 'lib/ruby/riddl/client.rb', line 166 def get(parameters = []) #{{{ exec_request('GET',parameters,false) end |
#patch(parameters = []) ⇒ Object
}}}
187 188 189 |
# File 'lib/ruby/riddl/client.rb', line 187 def patch(parameters = []) #{{{ exec_request('PATCH',parameters,false) end |
#post(parameters = []) ⇒ Object
}}}
173 174 175 |
# File 'lib/ruby/riddl/client.rb', line 173 def post(parameters = []) #{{{ exec_request('POST',parameters,false) end |
#put(parameters = []) ⇒ Object
}}}
180 181 182 |
# File 'lib/ruby/riddl/client.rb', line 180 def put(parameters = []) #{{{ exec_request('PUT',parameters,false) end |
#request(what) ⇒ Object
}}}
201 202 203 |
# File 'lib/ruby/riddl/client.rb', line 201 def request(what) #{{{ priv_request(what,false) end |
#simulate_delete(parameters = []) ⇒ Object
}}}
197 198 199 |
# File 'lib/ruby/riddl/client.rb', line 197 def simulate_delete(parameters = []) #{{{ exec_request('DELETE',parameters,true) end |
#simulate_get(parameters = []) ⇒ Object
}}}
169 170 171 |
# File 'lib/ruby/riddl/client.rb', line 169 def simulate_get(parameters = []) #{{{ exec_request('GET',parameters,true) end |
#simulate_patch(parameters = []) ⇒ Object
}}}
190 191 192 |
# File 'lib/ruby/riddl/client.rb', line 190 def simulate_patch(parameters = []) #{{{ exec_request('PATCH',parameters,true) end |
#simulate_post(parameters = []) ⇒ Object
}}}
176 177 178 |
# File 'lib/ruby/riddl/client.rb', line 176 def simulate_post(parameters = []) #{{{ exec_request('POST',parameters,true) end |
#simulate_put(parameters = []) ⇒ Object
}}}
183 184 185 |
# File 'lib/ruby/riddl/client.rb', line 183 def simulate_put(parameters = []) #{{{ exec_request('PUT',parameters,true) end |
#simulate_request(what) ⇒ Object
}}}
204 205 206 |
# File 'lib/ruby/riddl/client.rb', line 204 def simulate_request(what) #{{{ priv_request(what,true) end |
#ws(&blk) ⇒ Object
{{{
152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/ruby/riddl/client.rb', line 152 def ws(&blk) #{{{ EM.run do conn = Faye::WebSocket::Client.new((@base + @rpath).sub(/^http/,'ws')) if @options[:debug] conn.on :error do |e| @options[:debug].puts "WS ERROR: #{e}" end end blk.call(conn) end end |