Class: Sinclair::MethodDefinition Private
- Inherits:
-
Object
- Object
- Sinclair::MethodDefinition
- Includes:
- OptionsParser
- Defined in:
- lib/sinclair/method_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.
Definition of the code or block to be aded as method
Constant Summary collapse
- DEFAULT_OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default options of initialization
{ cached: false }.freeze
Instance Attribute Summary
Attributes included from OptionsParser
Instance Method Summary collapse
-
#build(klass) ⇒ Symbol
private
Adds the method to given klass.
-
#initialize(name, code = nil, **options, &block) ⇒ MethodDefinition
constructor
private
Returns a new instance of MethodDefinition.
Methods included from OptionsParser
Constructor Details
#initialize(name, code) ⇒ MethodDefinition #initialize(name, &block) ⇒ MethodDefinition
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 MethodDefinition
31 32 33 34 35 36 |
# File 'lib/sinclair/method_definition.rb', line 31 def initialize(name, code = nil, **, &block) @name = name @code = code @options = DEFAULT_OPTIONS.merge() @block = block end |
Instance Method Details
#build(klass) ⇒ Symbol
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.
Adds the method to given klass
86 87 88 89 90 91 92 |
# File 'lib/sinclair/method_definition.rb', line 86 def build(klass) if code.is_a?(String) build_code_method(klass) else build_block_method(klass) end end |