Class: TkInspectRails::SqlPanel::Base
- Inherits:
-
Object
- Object
- TkInspectRails::SqlPanel::Base
- Defined in:
- lib/tk_inspect_rails/sql_panel/base.rb
Instance Attribute Summary collapse
-
#main_component ⇒ Object
Returns the value of attribute main_component.
-
#tk_root ⇒ Object
Returns the value of attribute tk_root.
Instance Method Summary collapse
-
#create_menu ⇒ Object
So far, we only register key accelerators.
- #create_root ⇒ Object
- #execute_sql(expression) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #refresh ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
7 8 9 10 |
# File 'lib/tk_inspect_rails/sql_panel/base.rb', line 7 def initialize @tk_root = nil @main_component = nil end |
Instance Attribute Details
#main_component ⇒ Object
Returns the value of attribute main_component.
5 6 7 |
# File 'lib/tk_inspect_rails/sql_panel/base.rb', line 5 def main_component @main_component end |
#tk_root ⇒ Object
Returns the value of attribute tk_root.
4 5 6 |
# File 'lib/tk_inspect_rails/sql_panel/base.rb', line 4 def tk_root @tk_root end |
Instance Method Details
#create_menu ⇒ Object
So far, we only register key accelerators. Menus are better inherited from main console
29 30 31 |
# File 'lib/tk_inspect_rails/sql_panel/base.rb', line 29 def @tk_root.tk_item.native_item.bind('Command-r', -> { main_component.execute_sql(nil) }) end |
#create_root ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/tk_inspect_rails/sql_panel/base.rb', line 16 def create_root @tk_root = TkComponent::Window.new(title: "SQL Panel") @main_component = RootComponent.new @main_component.sql_panel = self @tk_root.place_root_component(@main_component) end |
#execute_sql(expression) ⇒ Object
24 25 26 |
# File 'lib/tk_inspect_rails/sql_panel/base.rb', line 24 def execute_sql(expression) ActiveRecord::Base.connection.execute(expression) end |
#refresh ⇒ Object
12 13 14 |
# File 'lib/tk_inspect_rails/sql_panel/base.rb', line 12 def refresh @main_component.nil? ? create_root : @main_component.regenerate end |