Sha256: c870b676090194056d1dba674aa5bf548677842197de8d7381ef81739be47aac

Contents?: true

Size: 1.81 KB

Versions: 6

Compression:

Stored size: 1.81 KB

Contents

Dir[File.join(__dir__, '/endpoints/*.rb')].each { |file| require file }

module FileboundClient
  # Module for resource endpoints
  module Endpoints
    # Sets up macros for use by endpoints and includes all endpoints
    # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
    def self.included(klass)
      klass.instance_eval do
        # @!macro [attach] fb.allow_new
        # Returns a new empty resource with defaulted values
        # @return [Hash] a new hash of $1
        def self.allow_new(name)
          define_method("#{name}_new") do
            get('/empty', template: name.to_s)
          end
        end

        # @!macro [attach] fb.allow_all
        # Returns an array $1 hashes
        # @param [Hash] query_params params to pass to the request
        # @return [Array] an array of $1 hashes
        def self.allow_all(name)
          define_method(name.to_s) do |query_params = nil|
            get("/#{name}", query_params)
          end
        end
      end

      klass.class_eval do
        include FileboundClient::Endpoints::Projects
        include FileboundClient::Endpoints::Files
        include FileboundClient::Endpoints::Documents
        include FileboundClient::Endpoints::Version
        include FileboundClient::Endpoints::Assignments
        include FileboundClient::Endpoints::Dividers
        include FileboundClient::Endpoints::DocumentBinaryData
        include FileboundClient::Endpoints::EFormData
        include FileboundClient::Endpoints::EFormDetail
        include FileboundClient::Endpoints::Separators
        include FileboundClient::Endpoints::Query
        include FileboundClient::Endpoints::Users
        include FileboundClient::Endpoints::Routes
        include FileboundClient::Endpoints::RoutedItems
      end
    end
    # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
filebound_client-0.3.5 lib/filebound_client/endpoints.rb
filebound_client-0.3.4 lib/filebound_client/endpoints.rb
filebound_client-0.3.3 lib/filebound_client/endpoints.rb
filebound_client-0.3.2 lib/filebound_client/endpoints.rb
filebound_client-0.3.1 lib/filebound_client/endpoints.rb
filebound_client-0.3.0 lib/filebound_client/endpoints.rb