Sha256: 4932dee73a02d795b5e979d1c0562740905cd9554f949c505318ac5dbcc5da8c

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 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
      # @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

      # String to be executed within the class
      # @return [String]
      def code_string
        "#{name} :#{arguments.join(', :')}"
      end

      # String to be executed within the class running code to change the class itself
      #
      # @see code_string
      # @return [String]
      def class_code_string
        <<-CODE
          class << self
            #{code_string}
          end
        CODE
      end

      private

      attr_reader :arguments

      # @method arguments
      # @api private
      # @private
      #
      # parameters to be passed as arguments to the call
      #
      # @return [Array<Symbol,String>]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinclair-1.10.0 lib/sinclair/method_definition/call_definition.rb