Module: Fern::Api::ClassMethods

Defined in:
lib/fern/api.rb

Constant Summary collapse

VERBS =
%i[delete get patch post put].freeze

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



16
17
18
19
20
21
22
# File 'lib/fern/api.rb', line 16

def method_missing(method_name, *args, &block)
  if VERBS.include?(method_name)
    endpoint(args[0], &block)
  else
    super
  end
end

Instance Method Details

#endpoint(name, &block) ⇒ Object



12
13
14
# File 'lib/fern/api.rb', line 12

def endpoint(name, &block)
  Endpoint.new(self, name: name, &block)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/fern/api.rb', line 24

def respond_to_missing?(method_name, include_private = false)
  VERBS.include?(method_name) || super
end