Class: ConvenientService::Support::DependencyContainer::Entities::Method Private
- Inherits:
-
Object
- Object
- ConvenientService::Support::DependencyContainer::Entities::Method
- Includes:
- Copyable
- Defined in:
- lib/convenient_service/support/dependency_container/entities/method.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.
Instance Attribute Summary collapse
- #alias_slug ⇒ Object readonly private
- #body ⇒ Object readonly private
- #scope ⇒ Object readonly private
- #slug ⇒ Object readonly private
Instance Method Summary collapse
- #==(other) ⇒ Boolean? private
- #define_in_module!(mod) ⇒ ConvenientService::Support::DependencyContainer::Entities::Method private
- #initialize(slug:, scope:, body:, alias_slug: "") ⇒ void constructor private
- #name ⇒ Symbol private
- #namespaces ⇒ Array<ConvenientService::Support::DependencyContainer::Entities::Namespace> private
- #to_arguments ⇒ ConvenientService::Support::Arguments private
- #to_kwargs ⇒ Hash{Symbol => Object} private
Methods included from Copyable
Constructor Details
#initialize(slug:, scope:, body:, alias_slug: "") ⇒ void
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.
46 47 48 49 50 51 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 46 def initialize(slug:, scope:, body:, alias_slug: "") @slug = slug @scope = scope @body = body @alias_slug = alias_slug end |
Instance Attribute Details
#alias_slug ⇒ Object (readonly)
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.
37 38 39 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 37 def alias_slug @alias_slug end |
#body ⇒ Object (readonly)
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.
31 32 33 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 31 def body @body end |
#scope ⇒ Object (readonly)
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.
25 26 27 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 25 def scope @scope end |
#slug ⇒ Object (readonly)
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.
19 20 21 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 19 def slug @slug end |
Instance Method Details
#==(other) ⇒ Boolean?
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.
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 107 def ==(other) return unless other.instance_of?(self.class) return false if slug != other.slug return false if scope != other.scope return false if body != other.body return false if alias_slug != other.alias_slug true end |
#define_in_module!(mod) ⇒ ConvenientService::Support::DependencyContainer::Entities::Method
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.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 71 def define_in_module!(mod) ## # NOTE: `innermost_namespace` is just `mod`, when `namespaces` are empty. # innermost_namespace = namespaces.reduce(mod) do |namespace, sub_namespace| already_defined_sub_namespace = namespace.namespaces.find_by(name: sub_namespace.name) ## # NOTE: # - Reuses already defined namespace from previous "imports". # - In contrast, same methods are always redefined. # next already_defined_sub_namespace if already_defined_sub_namespace namespace.namespaces << sub_namespace namespace.define_method(sub_namespace.name) { sub_namespace.body.call } sub_namespace end ## # NOTE: # - Same methods are redefined. # - In contrast, same namespaces are always reused. # innermost_namespace.define_method(name, &body) self end |
#name ⇒ 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.
56 57 58 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 56 def name @name ||= alias_slug_parts.last || slug_parts.last end |
#namespaces ⇒ Array<ConvenientService::Support::DependencyContainer::Entities::Namespace>
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.
63 64 65 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 63 def namespaces @namespaces ||= (alias_slug_parts.any? ? alias_slug_parts : slug_parts).slice(0..-2).map { |part| Entities::Namespace.new(name: part) } end |
#to_arguments ⇒ ConvenientService::Support::Arguments
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.
128 129 130 131 132 133 134 135 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 128 def to_arguments Support::Arguments.new( slug: slug, scope: scope, body: body, alias_slug: alias_slug ) end |
#to_kwargs ⇒ Hash{Symbol => Object}
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.
121 122 123 |
# File 'lib/convenient_service/support/dependency_container/entities/method.rb', line 121 def to_kwargs to_arguments.kwargs end |