Class: Orthoses::ActiveSupport::Configurable
- Inherits:
-
Object
- Object
- Orthoses::ActiveSupport::Configurable
- Defined in:
- lib/orthoses/active_support/configurable.rb
Overview
<= 6.1
def config_accessor(*names, instance_reader: true, instance_writer: true, instance_accessor: true)
>= 7
def config_accessor(*names, instance_reader: true, instance_writer: true, instance_accessor: true, default: nil)
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(loader) ⇒ Configurable
constructor
A new instance of Configurable.
Constructor Details
#initialize(loader) ⇒ Configurable
Returns a new instance of Configurable.
10 11 12 |
# File 'lib/orthoses/active_support/configurable.rb', line 10 def initialize(loader) @loader = loader end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/orthoses/active_support/configurable.rb', line 14 def call config_accessor = CallTracer::Lazy.new store = config_accessor.trace('ActiveSupport::Configurable::ClassMethods#config_accessor') do @loader.call end config_accessor.captures.each do |capture| mod_name = Utils.module_name(capture.method.receiver) or next content = store[mod_name] capture.argument[:names].each do |name| content << "def self.#{name}: () -> untyped" content << "def self.#{name}=: (untyped value) -> untyped" if capture.argument[:instance_accessor] content << "def #{name}: () -> untyped" if capture.argument[:instance_reader] content << "def #{name}=: (untyped value) -> untyped" if capture.argument[:instance_writer] end end end store end |