Class: Sinclair
- Inherits:
-
Object
- Object
- Sinclair
- Includes:
- OptionsParser
- Defined in:
- lib/sinclair.rb,
lib/sinclair/config.rb,
lib/sinclair/options.rb,
lib/sinclair/version.rb,
lib/sinclair/matchers.rb,
lib/sinclair/exception.rb,
lib/sinclair/input_hash.rb,
lib/sinclair/config_class.rb,
lib/sinclair/configurable.rb,
lib/sinclair/env_settable.rb,
lib/sinclair/config_builder.rb,
lib/sinclair/config_factory.rb,
lib/sinclair/method_builder.rb,
lib/sinclair/options_parser.rb,
lib/sinclair/options/builder.rb,
lib/sinclair/method_definition.rb,
lib/sinclair/method_definitions.rb,
lib/sinclair/matchers/add_method.rb,
lib/sinclair/method_builder/base.rb,
lib/sinclair/env_settable/builder.rb,
lib/sinclair/config/methods_builder.rb,
lib/sinclair/matchers/add_method_to.rb,
lib/sinclair/matchers/add_class_method.rb,
lib/sinclair/matchers/add_class_method_to.rb,
lib/sinclair/matchers/add_instance_method.rb,
lib/sinclair/method_definition/block_helper.rb,
lib/sinclair/matchers/add_instance_method_to.rb,
lib/sinclair/method_definition/block_definition.rb,
lib/sinclair/method_builder/block_method_builder.rb,
lib/sinclair/method_definition/string_definition.rb,
lib/sinclair/method_builder/string_method_builder.rb
Overview
Builder that add instance methods to a class
Direct Known Subclasses
Config::MethodsBuilder, EnvSettable::Builder, Options::Builder
Defined Under Namespace
Modules: ConfigClass, Configurable, EnvSettable, Matchers, OptionsParser Classes: Config, ConfigBuilder, ConfigFactory, Exception, InputHash, MethodBuilder, MethodDefinition, MethodDefinitions, Options
Constant Summary collapse
- VERSION =
'1.6.4'
Instance Attribute Summary
Attributes included from OptionsParser
Instance Method Summary collapse
-
#add_class_method(name, code = nil, **options, &block) ⇒ Array<MethodDefinition>
Add a method to the method list to be created on klass.
-
#add_method(name, code = nil, **options, &block) ⇒ Array<MethodDefinition>
Add a method to the method list to be created on klass instances.
-
#build ⇒ Array<MethodDefinition>
builds all the methods added into the klass.
-
#eval_and_add_method(name, &block) ⇒ Array<MethodDefinition>
Evaluetes a block which will result in a String, the method code.
-
#initialize(klass, options = {}) ⇒ Sinclair
constructor
Returns a new instance of Sinclair.
Methods included from OptionsParser
Constructor Details
#initialize(klass, options = {}) ⇒ Sinclair
Returns a new instance of Sinclair
151 152 153 154 |
# File 'lib/sinclair.rb', line 151 def initialize(klass, = {}) @klass = klass @options = end |
Instance Method Details
#add_class_method(name, code, **options) ⇒ Array<MethodDefinition> #add_class_method(name, **options, &block) ⇒ Array<MethodDefinition>
Add a method to the method list to be created on klass
271 272 273 274 275 |
# File 'lib/sinclair.rb', line 271 def add_class_method(name, code = nil, **, &block) class_definitions.add( name, code, **, &block ) end |
#add_method(name, code, **options) ⇒ Array<MethodDefinition> #add_method(name, **options, &block) ⇒ Array<MethodDefinition>
Add a method to the method list to be created on klass instances
225 226 227 228 229 |
# File 'lib/sinclair.rb', line 225 def add_method(name, code = nil, **, &block) definitions.add( name, code, **, &block ) end |
#build ⇒ Array<MethodDefinition>
builds all the methods added into the klass
174 175 176 177 |
# File 'lib/sinclair.rb', line 174 def build builder.build_methods(definitions, MethodBuilder::INSTANCE_METHOD) builder.build_methods(class_definitions, MethodBuilder::CLASS_METHOD) end |
#eval_and_add_method(name, &block) ⇒ Array<MethodDefinition>
Evaluetes a block which will result in a String, the method code
347 348 349 |
# File 'lib/sinclair.rb', line 347 def eval_and_add_method(name, &block) add_method(name, instance_eval(&block)) end |