module RestAPIBuilder::APIClient

Public Instance Methods

define_resource_shortcuts(resources, resources_scope:, init_with:) click to toggle source
# File lib/rest_api_builder/api_client.rb, line 5
def define_resource_shortcuts(resources, resources_scope:, init_with:)
  resources.each do |name|
    class_name = RestAPIBuilder::Helpers::StringHelper.camelize(name.to_s)
    resource_class = Object.const_get("#{resources_scope}::#{class_name}")

    define_singleton_method(name) do
      init_with.call(resource_class)
    end
  end
end