lib/ruby-lokalise-api/resources/base.rb
def supports(*methods)
          methods.each do |m_data|
            # `method_name` - the method that the resource should support
            # `sub_path` - a string that has to be appended to a base path
            # `c_method` - method name to delegate the work to
            method_name, sub_path, c_method =
              m_data.is_a?(Array) ? m_data : [m_data, '', m_data]

            define_method method_name do |params = {}|
              path = instance_variable_get(:@path)
              # If there's a sub_path which is a string,
              # preserve the initial path to allow further chaining
              params = params.merge(_initial_path: path) if sub_path
              self.class.send c_method, instance_variable_get(:@client),
                              path + sub_path, params
            end
          end
        end
# Defines CRUD instance methods. In the simplest case it delegates work to the
# class method. In more complex case it is possible to specify sub-path and the
# class method name to call.
# Usage: `supports :update, :destroy, [:complex_method, '/sub/path', :update]`
Defines CRUD instance methods. In the simplest case it delegates work to the
class method. In more complex case it is possible to specify sub-path and the
class method name to call.
Defines CRUD instance methods . In the simplest case it delegates work to the class method . In more complex case it is possible to specify sub - path and the class method name to call .
def supports(*methods)
          methods.each do |m_data|
            method_name, sub_path, c_method =
              m_data.is_a?(Array) ? m_data : [m_data, '', m_data]
            define_method method_name do |params = {}|
              path = instance_variable_get(:@path)
              params = params.merge(_initial_path: path) if sub_path
              self.class.send c_method, instance_variable_get(:@client),
                              path + sub_path, params
            end
          end
        end
def supports ( * methods ) methods . each do | m_data | method_name , sub_path , c_method = m_data . is_a? ( Array ) ? m_data : [ m_data , '' , m_data ] define_method method_name do | params = { } | path = instance_variable_get ( :@path ) params = params . merge ( _initial_path : path ) if sub_path self . class . send c_method , instance_variable_get ( :@client ) , path + sub_path , params end end end
Defines CRUD instance methods.
Defines CRUD instance methods .
# `method_name` - the method that the resource should support # `sub_path` - a string that has to be appended to a base path # `c_method` - method name to delegate the work to # If there's a sub_path which is a string, # preserve the initial path to allow further chaining
methods