Class: RbsActivesupport::Include
- Inherits:
-
Object
- Object
- RbsActivesupport::Include
- Defined in:
- lib/rbs_activesupport/include.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
: RBS::Namespace.
-
#module_path ⇒ Object
readonly
: RBS::Namespace.
-
#options ⇒ Object
readonly
: Hash[Symbol, untyped].
Instance Method Summary collapse
-
#classmethods? ⇒ Boolean
: boolish.
-
#concern? ⇒ Boolean
: boolish.
-
#explicit? ⇒ Boolean
: bool.
-
#implicit? ⇒ Boolean
: bool.
-
#initialize(context, module_path, options) ⇒ Include
constructor
A new instance of Include.
-
#method_calls_in_included_block ⇒ Object
: Array.
- #module ⇒ Object
- #module_name ⇒ Object
-
#nested_includes ⇒ Object
: Array.
-
#private? ⇒ Boolean
: bool.
-
#public? ⇒ Boolean
: bool.
Constructor Details
#initialize(context, module_path, options) ⇒ Include
Returns a new instance of Include.
14 15 16 17 18 |
# File 'lib/rbs_activesupport/include.rb', line 14 def initialize(context, module_path, ) #: void @context = context @module_path = module_path = end |
Instance Attribute Details
#context ⇒ Object (readonly)
: RBS::Namespace
7 8 9 |
# File 'lib/rbs_activesupport/include.rb', line 7 def context @context end |
#module_path ⇒ Object (readonly)
: RBS::Namespace
8 9 10 |
# File 'lib/rbs_activesupport/include.rb', line 8 def module_path @module_path end |
#options ⇒ Object (readonly)
: Hash[Symbol, untyped]
9 10 11 |
# File 'lib/rbs_activesupport/include.rb', line 9 def end |
Instance Method Details
#classmethods? ⇒ Boolean
: boolish
48 49 50 51 52 |
# File 'lib/rbs_activesupport/include.rb', line 48 def classmethods? #: boolish return false unless self.module self.module&.const_defined?(:ClassMethods) end |
#concern? ⇒ Boolean
: boolish
44 45 46 |
# File 'lib/rbs_activesupport/include.rb', line 44 def concern? #: boolish self.module&.singleton_class&.include?(ActiveSupport::Concern) end |
#explicit? ⇒ Boolean
: bool
54 55 56 |
# File 'lib/rbs_activesupport/include.rb', line 54 def explicit? #: bool !implicit? end |
#implicit? ⇒ Boolean
: bool
58 59 60 |
# File 'lib/rbs_activesupport/include.rb', line 58 def implicit? #: bool .fetch(:implicit, false) end |
#method_calls_in_included_block ⇒ Object
: Array
70 71 72 73 74 75 76 |
# File 'lib/rbs_activesupport/include.rb', line 70 def method_calls_in_included_block #: Array[Parser::MethodCall] return [] unless module_name return [] unless parser method_calls = parser.method_calls[module_name] || [] method_calls.select(&:included) end |
#module ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/rbs_activesupport/include.rb', line 35 def module #: Module? return unless module_name modname = module_name.to_s.delete_suffix("::") return unless Object.const_defined?(modname) Object.const_get(modname) end |
#module_name ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rbs_activesupport/include.rb', line 21 def module_name #: RBS::Namespace? namespace = @context loop do modname = namespace + module_path return modname if Object.const_defined?(modname.to_s.delete_suffix("::")) break if namespace.empty? namespace = namespace.parent end end |
#nested_includes ⇒ Object
: Array
62 63 64 65 66 67 68 |
# File 'lib/rbs_activesupport/include.rb', line 62 def nested_includes #: Array[Parser::MethodCall] return [] unless module_name return [] unless parser method_calls = parser.method_calls[module_name] || [] method_calls.select { |call| call.name == :include && !call.included } end |
#private? ⇒ Boolean
: bool
82 83 84 |
# File 'lib/rbs_activesupport/include.rb', line 82 def private? #: bool .fetch(:private, false) end |
#public? ⇒ Boolean
: bool
78 79 80 |
# File 'lib/rbs_activesupport/include.rb', line 78 def public? #: bool !private? end |