Class: RESTfulAdhearsion
- Inherits:
-
Object
- Object
- RESTfulAdhearsion
- Defined in:
- lib/restful_adhearsion.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ # Note: :user and :password are non-existent by default :host => "localhost", :port => "5000", :path_nesting => "/" }
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ RESTfulAdhearsion
constructor
A new instance of RESTfulAdhearsion.
- #method_missing(method_name, *args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ RESTfulAdhearsion
Returns a new instance of RESTfulAdhearsion.
13 14 15 16 17 18 19 20 21 |
# File 'lib/restful_adhearsion.rb', line 13 def initialize(={}) @options = DEFAULT_OPTIONS.merge @path_nesting = @options.delete :path_nesting @host = @options.delete :host @port = @options.delete :port @url_beginning = "http://#{@host}:#{@port}#{@path_nesting}" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
23 24 25 |
# File 'lib/restful_adhearsion.rb', line 23 def method_missing(method_name, *args) JSON.parse RestClient::Resource.new(@url_beginning + method_name.to_s, @options).post(args.to_json) end |