Class: Sinclair::MethodDefinition::StringDefinition Abstract Private

Inherits:
Sinclair::MethodDefinition show all
Defined in:
lib/sinclair/method_definition/string_definition.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class is abstract.

Define an instance method from string

Author:

  • darthjee

Constant Summary

Constants inherited from Sinclair::MethodDefinition

DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Sinclair::MethodDefinition

#name

Attributes included from OptionsParser

#options

Instance Method Summary collapse

Methods inherited from Sinclair::MethodDefinition

#build, default_value, from

Methods included from OptionsParser

#options_object

Constructor Details

#initialize(name, code = nil, **options) ⇒ StringDefinition

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of StringDefinition.

Parameters:

  • name (String, Symbol)

    name of the method

  • code (String) (defaults to: nil)

    code to be evaluated as method

  • options (Hash)

    Options of construction

Options Hash (**options):

  • cached (Boolean)

    Flag telling to create a method with cache



17
18
19
20
# File 'lib/sinclair/method_definition/string_definition.rb', line 17

def initialize(name, code = nil, **options)
  @code = code
  super(name, **options)
end

Instance Method Details

#code_lineString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

codeline to be run inside the code

Returns:

  • (String)


28
29
30
# File 'lib/sinclair/method_definition/string_definition.rb', line 28

def code_line
  cached? ? code_with_cache : code
end