Class: Simplenet::Client::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/simplenet/client/base.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/simplenet/client/base.rb', line 20

def method_missing(method, *args, &block)
  if method.to_s.match(/by_[a-zA-Z0-9]+/)
    raise "undefined url. Calling from Base object?" if @fullurl.nil?
    begin
      simplenet_get("#{@fullurl}/#{method.to_s.gsub("_", "-")}/#{args.first}")
    rescue Simplenet::Exception::EntityNotFoundError
      []
    end
  else
    super
  end
end

Instance Method Details

#delete(id) ⇒ Object



6
7
8
# File 'lib/simplenet/client/base.rb', line 6

def delete(id)
  simplenet_delete("#{@fullurl}/#{id}")
end

#listObject



15
16
17
18
# File 'lib/simplenet/client/base.rb', line 15

def list
  raise "undefined url. Calling from Base object?" if @fullurl.nil?
  simplenet_get(@fullurl)
end

#show(id) ⇒ Object



10
11
12
13
# File 'lib/simplenet/client/base.rb', line 10

def show(id)
  raise "undefined url. Calling from Base object?" if @fullurl.nil?
  simplenet_get("#{@fullurl}/#{id}")
end