21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/rongcloud/api.rb', line 21
def member(url, options = {})
meth = if options[:as]
options[:as]
else
resources_name = name.split("::").last.downcase
resources_name_in_url = "/#{resources_name}/"
raise ArgumentError unless url.start_with?(resources_name_in_url)
url.delete_prefix(resources_name_in_url)
.delete_suffix(".json")
.tr("/", "_")
.downcase
end
format = options[:format] || :form
define_method(meth) do |payload, opts = {}|
client.post(url, opts.merge(format => payload))
end
end
|