Sha256: 2e723974dfafc563ec2dbb3e8fece204f40ccb32ba368420408916ee4fd989ff

Contents?: true

Size: 1.18 KB

Versions: 16

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

class Sinclair
  class MethodDefinition
    # @api private
    # @author darthjee
    #
    # Define a call of method to e done within the class
    class CallDefinition < MethodDefinition
      build_with MethodBuilder::CallMethodBuilder

      # @param method_name [Symbol] method to be called
      # @param arguments [Array<Symbol,String>] parameters to be passed as
      #   arguments to the call
      def initialize(method_name, *arguments)
        @arguments = arguments
        super(method_name)
      end

      default_value :block?, false
      default_value :string?, false

      # Block to be evaluated by the class when adding methods
      #
      # The block will be a call from +method_name+ passing +arguments+
      #   as arguments
      # @return [Proc]
      def code_block
        method_name = name
        args = arguments

        proc do
          send(method_name, *args)
        end
      end

      private

      attr_reader :arguments
      # @method arguments
      # @api private
      # @private
      #
      # Arguments to be passed when calling the method inside the block
      #
      # @return [Array<Object>]
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sinclair-2.1.1 lib/sinclair/method_definition/call_definition.rb
sinclair-2.1.0 lib/sinclair/method_definition/call_definition.rb
sinclair-2.0.1 lib/sinclair/method_definition/call_definition.rb
sinclair-2.0.0 lib/sinclair/method_definition/call_definition.rb
sinclair-1.16.3 lib/sinclair/method_definition/call_definition.rb
sinclair-1.16.2 lib/sinclair/method_definition/call_definition.rb
sinclair-1.16.1 lib/sinclair/method_definition/call_definition.rb
sinclair-1.16.0 lib/sinclair/method_definition/call_definition.rb
sinclair-1.15.0 lib/sinclair/method_definition/call_definition.rb
sinclair-1.14.2 lib/sinclair/method_definition/call_definition.rb
sinclair-1.14.1 lib/sinclair/method_definition/call_definition.rb
sinclair-1.14.0 lib/sinclair/method_definition/call_definition.rb
sinclair-1.13.0 lib/sinclair/method_definition/call_definition.rb
sinclair-1.12.1 lib/sinclair/method_definition/call_definition.rb
sinclair-1.12.0 lib/sinclair/method_definition/call_definition.rb
sinclair-1.11.0 lib/sinclair/method_definition/call_definition.rb