Class: Kintone::Client::Path

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

Constant Summary collapse

BASE_PATH =
'/k/v1'

Instance Method Summary collapse

Constructor Details

#initialize(conn, auth, path) ⇒ Path

Returns a new instance of Path.



50
51
52
53
54
# File 'lib/kintone/client/client.rb', line 50

def initialize(conn, auth, path)
  @conn = conn
  @auth = auth
  @path = path
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/kintone/client/client.rb', line 128

def method_missing(method_name, *args, &block)
  method_name = method_name.to_s

  if %w(get post put delete post_json put_json delete_json).include?(method_name)
    case args.length
    when 0
      args = nil
    when 1
      args = args.first
    end

    options = {}

    if method_name =~ /_json\z/
      method_name.sub!(/_json\z/, '')
      options[:json] = true
    end

    request(method_name, args, options, &block)
  else
    unless args.length.zero?
      raise ArgumentError, "wrong number of arguments (#{args.length} for 0)"
    end

    self.class.new(@conn, @auth, @path + '/' + method_name.to_s)
  end
end