Sha256: 4865b896e4386af7846dae9178298afe3582e7d1de0aff0dbb0cabf9ff56b5d3

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

class Sinclair
  # @api private
  # @author darthjee
  #
  # Class responsible for building methods
  class MethodBuilder
    autoload :Base,                'sinclair/method_builder/base'
    autoload :BlockMethodBuilder,  'sinclair/method_builder/block_method_builder'
    autoload :CallMethodBuilder,   'sinclair/method_builder/call_method_builder'
    autoload :StringMethodBuilder, 'sinclair/method_builder/string_method_builder'

    CLASS_METHOD = :class
    INSTANCE_METHOD = :instance

    # @param klass [Class] class to receive the method
    def initialize(klass)
      @klass = klass
    end

    # Builds methods
    #
    # @param definitions [MethodDefinitions] all methods
    #   definitions to be built
    # @param type [Symbol] type of method to be built
    #   - {CLASS_METHOD} : A class method will be built
    #   - {INSTANCE_METHOD} : An instance method will be built
    #
    # @return [MethodDefinitions]
    def build_methods(definitions, type)
      definitions.each do |definition|
        definition.build(klass, type)
      end
    end

    private

    # @attr_reader klass
    # @private
    # @api private
    # @!visibility public
    #
    # class to receive the method
    #
    # @return [Class]
    attr_reader :klass
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sinclair-2.1.1 lib/sinclair/method_builder.rb
sinclair-2.1.0 lib/sinclair/method_builder.rb
sinclair-2.0.1 lib/sinclair/method_builder.rb
sinclair-2.0.0 lib/sinclair/method_builder.rb
sinclair-1.16.3 lib/sinclair/method_builder.rb
sinclair-1.16.2 lib/sinclair/method_builder.rb