Class: Yoda::Model::Values::ModuleValue
- Defined in:
- lib/yoda/model/values/module_value.rb
Instance Attribute Summary collapse
-
#namespace_object ⇒ Object
readonly
Returns the value of attribute namespace_object.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #defined_files ⇒ Array<[String, Integer]>
- #docstring ⇒ Object
-
#initialize(registry, namespace_object) ⇒ ModuleValue
constructor
A new instance of ModuleValue.
- #methods(visibility: nil) ⇒ Array<Functions::Base>
- #namespace ⇒ Object
- #path ⇒ String
Constructor Details
#initialize(registry, namespace_object) ⇒ ModuleValue
Returns a new instance of ModuleValue.
9 10 11 12 13 14 |
# File 'lib/yoda/model/values/module_value.rb', line 9 def initialize(registry, namespace_object) fail ArgumentError, registry unless registry.is_a?(Registry) fail ArgumentError, namespace_object unless namespace_object.is_a?(::YARD::CodeObjects::NamespaceObject) || namespace_object.is_a?(::YARD::CodeObjects::Proxy) @registry = registry @namespace_object = namespace_object end |
Instance Attribute Details
#namespace_object ⇒ Object (readonly)
Returns the value of attribute namespace_object.
5 6 7 |
# File 'lib/yoda/model/values/module_value.rb', line 5 def namespace_object @namespace_object end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
5 6 7 |
# File 'lib/yoda/model/values/module_value.rb', line 5 def registry @registry end |
Instance Method Details
#defined_files ⇒ Array<[String, Integer]>
43 44 45 |
# File 'lib/yoda/model/values/module_value.rb', line 43 def defined_files namespace.files end |
#docstring ⇒ Object
38 39 40 |
# File 'lib/yoda/model/values/module_value.rb', line 38 def docstring namespace.docstring end |
#methods(visibility: nil) ⇒ Array<Functions::Base>
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/yoda/model/values/module_value.rb', line 17 def methods(visibility: nil) return [] if namespace_object.type == :proxy @methods ||= begin opts = { scope: :class, visibility: visibility }.compact class_methods = namespace_object.meths(opts).map { |meth| Functions::Method.new(meth) } + constructors class_method_names = Set.new(class_methods.map(&:name)) parent_meths = parent_methods(visibility: visibility).reject { |m| class_method_names.include?(m.name) } class_methods + parent_meths end end |
#namespace ⇒ Object
33 34 35 |
# File 'lib/yoda/model/values/module_value.rb', line 33 def namespace namespace_object end |
#path ⇒ String
29 30 31 |
# File 'lib/yoda/model/values/module_value.rb', line 29 def path "#{namespace.path}.#{namespace.type == :class ? 'class' : 'module'}" end |