Sha256: cb0baae7199c94c06d76671db851f84f31664cbefea22fbeede38cda204ec4e2

Contents?: true

Size: 959 Bytes

Versions: 1

Compression:

Stored size: 959 Bytes

Contents

# frozen_string_literal: true

module DerivationEndpoint
  module Attachment
    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      ATTACHER_DERIVATION_METHODS = ["derivation_url", "redirection_url"].freeze

      def derivation_endpoint(method, prefix: nil, options: nil)
        Validation.check_object_class(method, [String, Symbol])
        Validation.check_object_class(prefix, [String, Symbol, NilClass])
        Validation.check_object_class(options, [Hash, NilClass])

        define_derivation_methods(method, prefix, options)
      end

      private

      def define_derivation_methods(method, prefix, options)
        ATTACHER_DERIVATION_METHODS.each do |attacher_method|
          define_method(:"#{method}_#{attacher_method}") do
            attacher = Attacher.new(self, method, prefix, options)
            attacher.public_send(attacher_method)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
derivation_endpoint-0.1.0 lib/derivation_endpoint/attachment.rb