Module: MaybeYouMeant::Config

Defined in:
lib/maybeyoumeant/config.rb

Class Method Summary collapse

Class Method Details

.add_to_historyObject



42
43
44
# File 'lib/maybeyoumeant/config.rb', line 42

def self.add_to_history
  @add_to_history
end

.add_to_history=(enabled) ⇒ Object

When true and a nearby method is called the history is manipulated to have the nearby method name. Defaults to true. This is done with a simple search and replace and may not be perfect, especially for short methods. Say object foo has a method ‘foob’ you will get the following in your history: foo.foo -> foob.foob



38
39
40
# File 'lib/maybeyoumeant/config.rb', line 38

def self.add_to_history=(enabled)
  @add_to_history = true
end

.ask_userObject



68
69
70
# File 'lib/maybeyoumeant/config.rb', line 68

def self.ask_user
  @ask_user
end

.ask_user=(enabled) ⇒ Object

When true, the nearby method is not called directly, but the user can decide if he wants to call it Defaults to false



64
65
66
# File 'lib/maybeyoumeant/config.rb', line 64

def self.ask_user=(enabled)
  @ask_user = enabled
end

.call_nearbyObject



26
27
28
# File 'lib/maybeyoumeant/config.rb', line 26

def self.call_nearby
  @call_nearby
end

.call_nearby=(enabled) ⇒ Object

When true if a nearby method is found it is automatically called. Defaults to true.



22
23
24
# File 'lib/maybeyoumeant/config.rb', line 22

def self.call_nearby=(enabled)
  @call_nearby = enabled
end

.debugObject

Indicates if debug logger is currently enabled.



14
15
16
# File 'lib/maybeyoumeant/config.rb', line 14

def self.debug
  MaybeYouMeant::StdErrLogger === MaybeYouMeant.logger
end

.debug=(enabled) ⇒ Object

Set to true to log when a nearby message is automatically called. Default value is true.



4
5
6
7
8
9
10
11
# File 'lib/maybeyoumeant/config.rb', line 4

def self.debug=(enabled)
  raise 'Debug can only be set to true or false.' unless enabled == true || enabled == false
  if enabled
    MaybeYouMeant.logger = MaybeYouMeant::StdErrLogger.new
  else
    MaybeYouMeant.logger = MaybeYouMeant::NilLogger.new
  end
end

.remove_from_historyObject

When true and a nearby method is called the history is manipulated to have the line with the incorrect method name removed. Defaults to false.



51
52
53
# File 'lib/maybeyoumeant/config.rb', line 51

def self.remove_from_history(enabled)
  @remove_from_history = enabled
end