Method: Hyperclient::Resource#method_missing

Defined in:
lib/hyperclient/resource.rb

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Delegate the method to various elements of the resource.

This allows ‘api.posts` instead of `api.links.posts.resource` as well as api.posts(id: 1) assuming posts is a link.



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/hyperclient/resource.rb', line 108

def method_missing(method, *args, &block)
  if args.any? && args.first.is_a?(Hash)
    _links.send(method, [], &block)._expand(*args)
  elsif !Array.method_defined?(method)
    i[_attributes _embedded _links].each do |target|
      target = send(target)
      return target.send(method, *args, &block) if target.respond_to?(method.to_s)
    end
    super
  end
end