Top Level Namespace

Defined Under Namespace

Modules: RailsConsolePro

Instance Method Summary collapse

Instance Method Details

#compare(&block) ⇒ Object



59
60
61
# File 'lib/rails_console_pro/global_methods.rb', line 59

def compare(&block)
  RailsConsolePro::Commands.compare(&block)
end

#diff(object1, object2) ⇒ Object



39
40
41
# File 'lib/rails_console_pro/global_methods.rb', line 39

def diff(object1, object2)
  RailsConsolePro::Commands.diff(object1, object2)
end

#explain(relation_or_model, *args) ⇒ Object



8
9
10
# File 'lib/rails_console_pro/global_methods.rb', line 8

def explain(relation_or_model, *args)
  RailsConsolePro::Commands.explain(relation_or_model, *args)
end

#introspect(model_class, *options) ⇒ Object



55
56
57
# File 'lib/rails_console_pro/global_methods.rb', line 55

def introspect(model_class, *options)
  RailsConsolePro::Commands.introspect(model_class, *options)
end

#jobs(options = {}) ⇒ Object



47
48
49
# File 'lib/rails_console_pro/global_methods.rb', line 47

def jobs(options = {})
  RailsConsolePro::Commands.jobs(options)
end


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rails_console_pro/global_methods.rb', line 12

def navigate(model_or_string)
  pastel = RailsConsolePro::ColorHelper.pastel
  if model_or_string.is_a?(String)
    begin
      model = model_or_string.constantize
    rescue NameError
      puts pastel.red("Error: Could not find model '#{model_or_string}'")
      puts pastel.yellow("Make sure the model name is correct and loaded.")
      return nil
    end
  else
    model = model_or_string
  end

  unless RailsConsolePro::ModelValidator.valid_model?(model)
    puts pastel.red("Error: #{model} is not an ActiveRecord model")
    return nil
  end

  navigator = RailsConsolePro::AssociationNavigator.new(model)
  navigator.start
end

#profile(target = nil, *args, **kwargs, &block) ⇒ Object



43
44
45
# File 'lib/rails_console_pro/global_methods.rb', line 43

def profile(target = nil, *args, **kwargs, &block)
  RailsConsolePro::Commands.profile(target, *args, **kwargs, &block)
end

#query(model_class, &block) ⇒ Object



63
64
65
# File 'lib/rails_console_pro/global_methods.rb', line 63

def query(model_class, &block)
  RailsConsolePro::Commands.query(model_class, &block)
end

#schema(model_class) ⇒ Object

Global helper methods available in console



4
5
6
# File 'lib/rails_console_pro/global_methods.rb', line 4

def schema(model_class)
  RailsConsolePro::Commands.schema(model_class)
end

#snippets(action = :list, *args, **kwargs, &block) ⇒ Object



51
52
53
# File 'lib/rails_console_pro/global_methods.rb', line 51

def snippets(action = :list, *args, **kwargs, &block)
  RailsConsolePro::Commands.snippets(action, *args, **kwargs, &block)
end

#stats(model_class) ⇒ Object



35
36
37
# File 'lib/rails_console_pro/global_methods.rb', line 35

def stats(model_class)
  RailsConsolePro::Commands.stats(model_class)
end