Class: RbsActiverecord::Parser::IncludeExpander
- Inherits:
-
Object
- Object
- RbsActiverecord::Parser::IncludeExpander
- Defined in:
- lib/rbs_activerecord/parser/include_expander.rb,
lib/rbs_activerecord/parser/include_expander/module.rb
Defined Under Namespace
Classes: Module
Instance Attribute Summary collapse
-
#declarations ⇒ Object
readonly
: Hash[String, Array].
-
#model ⇒ Object
readonly
: RbsActiverecord::Model.
Class Method Summary collapse
Instance Method Summary collapse
-
#expand ⇒ Object
: void.
-
#initialize(model, declarations) ⇒ IncludeExpander
constructor
A new instance of IncludeExpander.
Constructor Details
#initialize(model, declarations) ⇒ IncludeExpander
Returns a new instance of IncludeExpander.
17 18 19 20 |
# File 'lib/rbs_activerecord/parser/include_expander.rb', line 17 def initialize(model, declarations) #: void @model = model @declarations = declarations end |
Instance Attribute Details
#declarations ⇒ Object (readonly)
: Hash[String, Array]
13 14 15 |
# File 'lib/rbs_activerecord/parser/include_expander.rb', line 13 def declarations @declarations end |
#model ⇒ Object (readonly)
: RbsActiverecord::Model
12 13 14 |
# File 'lib/rbs_activerecord/parser/include_expander.rb', line 12 def model @model end |
Class Method Details
.expand(model, declarations) ⇒ Object
8 9 10 |
# File 'lib/rbs_activerecord/parser/include_expander.rb', line 8 def self.(model, declarations) #: void new(model, declarations). end |
Instance Method Details
#expand ⇒ Object
: void
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rbs_activerecord/parser/include_expander.rb', line 22 def #: void declarations.each_value do |decls| loop do index = decls.index { |node| node.name == :include } break unless index included_module = decls.delete_at(index) included_blocks = included_blocks_for(included_module) included_blocks.reverse_each do |included| decls.insert(index, *block_body_of(included)) end end end end |