Module: Taro::Rails::DeclarationBuffer
- Included in:
- Taro::Rails
- Defined in:
- lib/taro/rails/declaration_buffer.rb
Overview
Buffers api declarations in rails controllers (e.g. ‘param :foo, …`) until the next action method is defined (e.g. `def create`).
Instance Method Summary collapse
- #apply_buffered_declaration(controller_class, action_name) ⇒ Object
- #buffered_declaration(controller_class) ⇒ Object
- #buffered_declarations ⇒ Object
- #pop_buffered_declaration(controller_class) ⇒ Object
Instance Method Details
#apply_buffered_declaration(controller_class, action_name) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/taro/rails/declaration_buffer.rb', line 13 def apply_buffered_declaration(controller_class, action_name) declaration = pop_buffered_declaration(controller_class) return unless declaration declaration.finalize(controller_class:, action_name:) Taro::Rails.apply(declaration:, controller_class:, action_name:) end |
#buffered_declaration(controller_class) ⇒ Object
4 5 6 7 |
# File 'lib/taro/rails/declaration_buffer.rb', line 4 def buffered_declaration(controller_class) buffered_declarations[controller_class] ||= Taro::Rails::Declaration.new(controller_class) end |
#buffered_declarations ⇒ Object
9 10 11 |
# File 'lib/taro/rails/declaration_buffer.rb', line 9 def buffered_declarations @buffered_declarations ||= {} end |
#pop_buffered_declaration(controller_class) ⇒ Object
22 23 24 |
# File 'lib/taro/rails/declaration_buffer.rb', line 22 def pop_buffered_declaration(controller_class) buffered_declarations.delete(controller_class) end |