Class: RESTfulAdhearsion

Inherits:
Object
  • Object
show all
Defined in:
lib/restful_adhearsion.rb,
lib/restful_adhearsion/version.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  # Note: :user and :password are non-existent by default
  :host => "localhost",
  :port => "5000",
  :path_nesting => "/"
}
VERSION =
"0.2.0"

Instance Method Summary collapse

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 = {})
  @options = DEFAULT_OPTIONS.merge options

  @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}restful_#{method_name.to_s}", @options).post(args.to_json)
end